0
Fork 0
mirror of https://github.com/logto-io/logto.git synced 2025-01-13 21:30:30 -05:00
logto/packages/core/src/middleware/koa-check-demo-app.ts
Gao Sun 91e2f055f2
feat(demo-app): implementation (3/3) (#1021)
* feat(core): seed demo app for fresh DB

* feat(core): throw 404 when demo app deleted

* fix(core): import

* fix: lockfile
2022-06-02 07:32:46 +00:00

22 lines
482 B
TypeScript

import { demoAppApplicationId } from '@logto/schemas/lib/seeds';
import { MiddlewareType } from 'koa';
import { findApplicationById } from '@/queries/application';
export default function koaCheckDemoApp<StateT, ContextT, ResponseBodyT>(): MiddlewareType<
StateT,
ContextT,
ResponseBodyT
> {
return async (ctx, next) => {
try {
await findApplicationById(demoAppApplicationId);
await next();
return;
} catch {
ctx.throw(404);
}
};
}