mirror of
https://github.com/logto-io/logto.git
synced 2025-01-27 21:39:16 -05:00
23 lines
482 B
TypeScript
23 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);
|
||
|
}
|
||
|
};
|
||
|
}
|