0
Fork 0
mirror of https://github.com/logto-io/logto.git synced 2024-12-30 20:33:54 -05:00

refactor(core): re-org files

This commit is contained in:
Gao Sun 2021-08-11 22:37:21 +08:00
parent 8c64cb5a08
commit 03b2997898
8 changed files with 17 additions and 16 deletions

View file

@ -4,10 +4,10 @@ import Koa from 'koa';
import koaLogger from 'koa-logger';
import koaErrorHandler from '@/middleware/koa-error-handler';
import { port } from '@/consts';
import { port } from '@/env/consts';
import koaUIProxy from '@/middleware/koa-ui-proxy';
import initOidc from './oidc';
import initRouter from './apis';
import initOidc from '@/oidc/init';
import initRouter from '@/routes/init';
export default async function initApp(app: Koa): Promise<void> {
app.use(koaErrorHandler());

View file

@ -1,14 +1,6 @@
import { assertEnv, getEnv } from '@/utils/env';
const signIn = assertEnv('UI_SIGN_IN_ROUTE');
export const routes = Object.freeze({
signIn: {
credentials: signIn,
consent: signIn + '/consent',
},
});
export const signIn = assertEnv('UI_SIGN_IN_ROUTE');
export const isProduction = getEnv('NODE_ENV') === 'production';
export const port = Number(getEnv('PORT', '3001'));
export const oidcIssuer = getEnv('OIDC_ISSUER', `http://localhost:${port}/oidc`);

View file

@ -6,8 +6,8 @@ import dotenv from 'dotenv';
dotenv.config();
import Koa from 'koa';
import initI18n from './init/i18n';
import initApp from './init/app';
import initI18n from './i18n/init';
import initApp from './app/init';
const app = new Koa();

View file

@ -3,7 +3,7 @@ import { MiddlewareType } from 'koa';
import proxy from 'koa-proxies';
import serveStatic from 'koa-static';
import { IRouterParamContext } from 'koa-router';
import { isProduction, mountedApps } from '@/consts';
import { isProduction, mountedApps } from '@/env/consts';
const PATH_TO_UI_DIST = '../ui/build/public';
const uiDistFiles = fs.readdirSync(PATH_TO_UI_DIST);

View file

@ -7,7 +7,8 @@ import postgresAdapter from '@/oidc/adapter';
import { fromKeyLike } from 'jose/jwk/from_key_like';
import { getEnv } from '@/utils/env';
import { findUserById } from '@/queries/user';
import { oidcIssuer, routes } from '@/consts';
import { oidcIssuer } from '@/env/consts';
import { routes } from '@/routes/consts';
export default async function initOidc(app: Koa): Promise<Provider> {
const privateKey = crypto.createPrivateKey(

View file

@ -0,0 +1,8 @@
import { signIn } from '@/env/consts';
export const routes = Object.freeze({
signIn: {
credentials: signIn,
consent: signIn + '/consent',
},
});