UNPKG

@appsemble/node-utils

Version:

NodeJS utilities used by Appsemble internally.

16 lines 786 B
import { assertKoaCondition } from '@appsemble/node-utils'; export function createScreenshotHandler({ getApp, getAppScreenshots }) { return async (ctx) => { // @ts-expect-error Messed up const { id } = ctx.params; const app = await getApp({ context: ctx }); assertKoaCondition(app != null, ctx, 404, 'App not found'); const appScreenshots = await getAppScreenshots({ app, context: ctx }); const appScreenshot = appScreenshots.find((screenshot) => screenshot.id === Number.parseInt(id)); assertKoaCondition(appScreenshot != null, ctx, 404, 'Screenshot not found'); const { mime, screenshot } = appScreenshot; ctx.type = mime; ctx.body = screenshot; }; } //# sourceMappingURL=screenshotHandler.js.map