0
Fork 0
mirror of https://github.com/logto-io/logto.git synced 2025-01-06 20:40:08 -05:00
logto/packages/core/src/init/router.ts

24 lines
709 B
TypeScript
Raw Normal View History

2021-06-27 07:44:05 -05:00
import Koa from 'koa';
import Router from 'koa-router';
import { Provider } from 'oidc-provider';
2021-07-23 10:10:54 -05:00
import signInRoutes from '@/routes/sign-in';
import registerRoutes from '@/routes/register';
import uiProxy from '@/proxies/ui';
import swaggerRoutes from '@/routes/swagger';
2021-06-27 07:44:05 -05:00
const createRouter = (provider: Provider): Router => {
2021-07-04 04:41:46 -05:00
const router = new Router({ prefix: '/api' });
2021-06-27 07:44:05 -05:00
2021-07-23 10:10:54 -05:00
router.use(signInRoutes(provider));
router.use(registerRoutes());
router.use(swaggerRoutes());
2021-06-27 07:44:05 -05:00
return router;
};
export default function initRouter(app: Koa, provider: Provider): Router {
const router = createRouter(provider);
2021-07-23 10:10:54 -05:00
app.use(router.routes()).use(uiProxy()).use(router.allowedMethods());
return router;
2021-06-27 07:44:05 -05:00
}