UNPKG

@appsemble/node-utils

Version:

NodeJS utilities used by Appsemble internally.

16 lines 762 B
import { assertKoaCondition } from '@appsemble/node-utils'; export function createReadmeHandler({ getApp, getAppReadmes }) { return async (ctx) => { // @ts-expect-error Messed up const { id } = ctx.params; const app = await getApp({ context: ctx, query: { attributes: ['id'] } }); assertKoaCondition(app != null, ctx, 404, 'App not found'); const appReadmes = await getAppReadmes({ app, context: ctx }); const appReadme = appReadmes.find((readme) => readme.id === Number.parseInt(id)); assertKoaCondition(appReadme != null, ctx, 404, 'Readme not found'); const { file } = appReadme; ctx.type = 'text/markdown'; ctx.body = file; }; } //# sourceMappingURL=readmeHandler.js.map