0
Fork 0
mirror of https://github.com/logto-io/logto.git synced 2025-01-27 21:39:16 -05:00
logto/packages/core/src/middleware/koa-check-demo-app.ts

23 lines
482 B
TypeScript
Raw Normal View History

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);
}
};
}