diff --git a/packages/core/src/adapter/node.ts b/packages/core/src/adapter/node.ts index 20cf6d3..c50a210 100644 --- a/packages/core/src/adapter/node.ts +++ b/packages/core/src/adapter/node.ts @@ -1,6 +1,6 @@ import { fileURLToPath } from 'node:url' import { basename } from 'node:path' -import { fromBuffer } from 'file-type' +import FileType from 'file-type' import { FileResponse } from '../index.js' import { readFile } from 'node:fs/promises' @@ -9,7 +9,7 @@ export { lookup } from 'node:dns/promises' export async function loadFile(url: string): Promise { if (url.startsWith('file://')) { const data = await readFile(fileURLToPath(url)) - const result = await fromBuffer(data) + const result = await FileType.fromBuffer(data) // https://stackoverflow.com/questions/8609289/convert-a-binary-nodejs-buffer-to-javascript-arraybuffer#answer-31394257 const buffer = data.buffer.slice(data.byteOffset, data.byteOffset + data.byteLength) return { mime: result?.mime, filename: basename(url), data: buffer } diff --git a/packages/core/src/index.ts b/packages/core/src/index.ts index 9d0c8c5..24a80d2 100644 --- a/packages/core/src/index.ts +++ b/packages/core/src/index.ts @@ -163,6 +163,8 @@ export class HTTP extends Service { } } + public isError = HTTPError.is + private _decoders: Dict = Object.create(null) constructor(config?: HTTP.Config)