diff --git a/api/api/v1/favourites/index.ts b/api/api/v1/favourites/index.ts index f13f608c..527099fd 100644 --- a/api/api/v1/favourites/index.ts +++ b/api/api/v1/favourites/index.ts @@ -81,7 +81,7 @@ export default apiRoute((app) => ); return context.json( - await Promise.all(favourites.map(async (note) => note.toApi(user))), + await Promise.all(favourites.map((note) => note.toApi(user))), 200, { Link: link, diff --git a/api/api/v1/instance/rules.ts b/api/api/v1/instance/rules.ts index 5b00e592..94a7a594 100644 --- a/api/api/v1/instance/rules.ts +++ b/api/api/v1/instance/rules.ts @@ -37,7 +37,7 @@ const route = createRoute({ }); export default apiRoute((app) => - app.openapi(route, async (context) => { + app.openapi(route, (context) => { return context.json( config.signups.rules.map((rule, index) => ({ id: String(index), diff --git a/api/api/v1/timelines/home.ts b/api/api/v1/timelines/home.ts index f418327f..2ef1761c 100644 --- a/api/api/v1/timelines/home.ts +++ b/api/api/v1/timelines/home.ts @@ -93,7 +93,7 @@ export default apiRoute((app) => ); return context.json( - await Promise.all(objects.map(async (note) => note.toApi(user))), + await Promise.all(objects.map((note) => note.toApi(user))), 200, { Link: link, diff --git a/api/api/v1/timelines/public.ts b/api/api/v1/timelines/public.ts index 96c4068e..aa191442 100644 --- a/api/api/v1/timelines/public.ts +++ b/api/api/v1/timelines/public.ts @@ -105,7 +105,7 @@ export default apiRoute((app) => ); return context.json( - await Promise.all(objects.map(async (note) => note.toApi(user))), + await Promise.all(objects.map((note) => note.toApi(user))), 200, { Link: link, diff --git a/classes/media/preprocessors/blurhash.ts b/classes/media/preprocessors/blurhash.ts index 188697f8..a90b3841 100644 --- a/classes/media/preprocessors/blurhash.ts +++ b/classes/media/preprocessors/blurhash.ts @@ -11,30 +11,29 @@ export class BlurhashPreprocessor implements MediaPreprocessor { const metadata = await sharp(arrayBuffer).metadata(); const blurhash = await new Promise((resolve) => { - (async () => - sharp(arrayBuffer) - .raw() - .ensureAlpha() - .toBuffer((err, buffer) => { - if (err) { - resolve(null); - return; - } + sharp(arrayBuffer) + .raw() + .ensureAlpha() + .toBuffer((err, buffer) => { + if (err) { + resolve(null); + return; + } - try { - resolve( - encode( - new Uint8ClampedArray(buffer), - metadata?.width ?? 0, - metadata?.height ?? 0, - 4, - 4, - ) as string, - ); - } catch { - resolve(null); - } - }))(); + try { + resolve( + encode( + new Uint8ClampedArray(buffer), + metadata?.width ?? 0, + metadata?.height ?? 0, + 4, + 4, + ) as string, + ); + } catch { + resolve(null); + } + }); }); return { file, blurhash }; diff --git a/classes/plugin/loader.test.ts b/classes/plugin/loader.test.ts index 70403bf7..8f1014a7 100644 --- a/classes/plugin/loader.test.ts +++ b/classes/plugin/loader.test.ts @@ -80,7 +80,7 @@ describe("PluginLoader", () => { test("parseManifestFile should parse JSON manifest", async () => { const manifestContent = { name: "test-plugin" }; Bun.file = jest.fn().mockReturnValue({ - text: async () => JSON.stringify(manifestContent), + text: () => Promise.resolve(JSON.stringify(manifestContent)), }); // biome-ignore lint/complexity/useLiteralKeys: Private method @@ -111,7 +111,7 @@ describe("PluginLoader", () => { }; mockReaddir.mockResolvedValue(["manifest.json"]); Bun.file = jest.fn().mockReturnValue({ - text: async () => JSON.stringify(manifestContent), + text: () => Promise.resolve(JSON.stringify(manifestContent)), }); manifestSchema.safeParseAsync = jest.fn().mockResolvedValue({ success: true, @@ -141,7 +141,7 @@ describe("PluginLoader", () => { }; mockReaddir.mockResolvedValue(["manifest.json"]); Bun.file = jest.fn().mockReturnValue({ - text: async () => JSON.stringify(manifestContent), + text: () => Promise.resolve(JSON.stringify(manifestContent)), }); manifestSchema.safeParseAsync = jest.fn().mockResolvedValue({ success: false, @@ -188,7 +188,7 @@ describe("PluginLoader", () => { ]) .mockResolvedValue(["manifest.json", "index.ts"]); Bun.file = jest.fn().mockReturnValue({ - text: async () => JSON.stringify(manifestContent), + text: () => Promise.resolve(JSON.stringify(manifestContent)), }); manifestSchema.safeParseAsync = jest.fn().mockResolvedValue({ success: true, diff --git a/classes/search/search-manager.ts b/classes/search/search-manager.ts index a7e17a3e..a07bb427 100644 --- a/classes/search/search-manager.ts +++ b/classes/search/search-manager.ts @@ -149,7 +149,7 @@ export class SonicSearchManager { * @param n Batch number * @param batchSize Size of the batch */ - private async getNthDatabaseAccountBatch( + private getNthDatabaseAccountBatch( n: number, batchSize = 1000, ): Promise[]> { @@ -172,7 +172,7 @@ export class SonicSearchManager { * @param n Batch number * @param batchSize Size of the batch */ - private async getNthDatabaseStatusBatch( + private getNthDatabaseStatusBatch( n: number, batchSize = 1000, ): Promise[]> { diff --git a/packages/database-interface/emoji.ts b/packages/database-interface/emoji.ts index 1e2941ff..0a702ddf 100644 --- a/packages/database-interface/emoji.ts +++ b/packages/database-interface/emoji.ts @@ -172,10 +172,10 @@ export class Emoji extends BaseInterface { * @param text The text to parse * @returns An array of emojis */ - public static async parseFromText(text: string): Promise { + public static parseFromText(text: string): Promise { const matches = text.match(emojiValidatorWithColons); if (!matches || matches.length === 0) { - return []; + return Promise.resolve([]); } return Emoji.manyFromSql( diff --git a/utils/api.ts b/utils/api.ts index a6f05fab..98214f14 100644 --- a/utils/api.ts +++ b/utils/api.ts @@ -395,8 +395,8 @@ export const setContextFormDataToObject = ( setTo: object, ): Context => { context.req.bodyCache.json = setTo; - context.req.parseBody = async () => context.req.bodyCache.json; - context.req.json = async () => context.req.bodyCache.json; + context.req.parseBody = () => Promise.resolve(context.req.bodyCache.json); + context.req.json = () => Promise.resolve(context.req.bodyCache.json); return context; }; diff --git a/utils/content_types.ts b/utils/content_types.ts index c21dc653..540820a0 100644 --- a/utils/content_types.ts +++ b/utils/content_types.ts @@ -47,11 +47,11 @@ export const urlToContentFormat = (url?: string): ContentFormat | null => { }; }; -export const mimeLookup = async (url: string) => { +export const mimeLookup = (url: string): Promise => { const naiveLookup = lookup(url.replace(new URL(url).search, "")); if (naiveLookup) { - return naiveLookup; + return Promise.resolve(naiveLookup); } const fetchLookup = fetch(url, {