perf: use undici instead of axios

This commit is contained in:
Starcea 2024-11-02 14:00:41 +09:00
commit 5a15d50cfc
No known key found for this signature in database
GPG key ID: B7A77E32374911E1
5 changed files with 59 additions and 97 deletions

20
src/http.ts Normal file
View file

@ -0,0 +1,20 @@
import { request } from 'undici'
export default class HTTP {
private readonly baseURL: string
private readonly headers: Record<string, string>
constructor({
baseURL,
headers,
}: { baseURL: string; headers: Record<string, string> }) {
this.baseURL = baseURL
this.headers = headers
}
async get(url: string) {
return request(`${new URL(url, this.baseURL)}`, {
headers: this.headers,
})
}
}