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

refactor: add @ path alias

This commit is contained in:
Gao Sun 2021-07-02 22:55:14 +08:00
parent 27590ec4ad
commit ba1d171353
No known key found for this signature in database
GPG key ID: 0F0EFA2E36639F31
9 changed files with 28 additions and 13 deletions

View file

@ -21,6 +21,7 @@
"koa-logger": "^3.2.1",
"koa-mount": "^4.0.0",
"koa-router": "^10.0.0",
"module-alias": "^2.2.2",
"oidc-provider": "^7.4.1",
"slonik": "^23.8.1",
"slonik-interceptor-preset": "^1.2.10"
@ -42,5 +43,8 @@
"node": "14",
"yarn": "1"
},
"_moduleAliases": {
"@": "./build"
},
"prettier": "@logto/essentials/.prettierrc.json"
}

View file

@ -1,6 +1,6 @@
import { createPool } from 'slonik';
import { createInterceptors } from 'slonik-interceptor-preset';
import { getEnv } from '../utils';
import { getEnv } from '@/utils';
const interceptors = [...createInterceptors()];

View file

@ -1,3 +1,5 @@
import 'module-alias/register';
import dotenv from 'dotenv';
dotenv.config();

View file

@ -2,12 +2,12 @@ import crypto from 'crypto';
import Koa from 'koa';
import mount from 'koa-mount';
import { Provider } from 'oidc-provider';
import postgresAdapter from '../oidc/adapter';
import postgresAdapter from '@/oidc/adapter';
import { fromKeyLike } from 'jose/jwk/from_key_like';
import { getEnv } from '../utils';
import { findUserById } from '../queries/user';
import { signInRoute } from '../consts';
import { getEnv } from '@/utils';
import { findUserById } from '@/queries/user';
import { signInRoute } from '@/consts';
export default async function initOidc(app: Koa, port: number): Promise<void> {
const privateKey = crypto.createPrivateKey(

View file

@ -3,8 +3,8 @@ import Koa from 'koa';
import Router from 'koa-router';
import { promisify } from 'util';
import stream from 'stream';
import { signInRoute } from '../consts';
import { getEnv } from '../utils';
import { signInRoute } from '@/consts';
import { getEnv } from '@/utils';
const pipeline = promisify(stream.pipeline);
const router = new Router();

View file

@ -2,9 +2,9 @@ import dayjs from 'dayjs';
import { AdapterFactory } from 'oidc-provider';
import { IdentifierSqlTokenType, sql, ValueExpressionType } from 'slonik';
import { OidcModelInstances, OidcModelInstanceDBEntry } from '@logto/schemas';
import pool from '../database/pool';
import { convertToIdentifiers } from '../database/utils';
import { conditional } from '../utils';
import pool from '@/database/pool';
import { convertToIdentifiers } from '@/database/utils';
import { conditional } from '@/utils';
export default function postgresAdapter(modelName: string) {
const { table, fields } = convertToIdentifiers(OidcModelInstances);

View file

@ -1,7 +1,7 @@
import { UserDBEntry, Users } from '@logto/schemas';
import { sql } from 'slonik';
import pool from '../database/pool';
import { convertToIdentifiers } from '../database/utils';
import pool from '@/database/pool';
import { convertToIdentifiers } from '@/database/utils';
const { table, fields } = convertToIdentifiers(Users);

View file

@ -1,7 +1,11 @@
{
"extends": "@logto/essentials/tsconfig.base",
"compilerOptions": {
"outDir": "build"
"outDir": "build",
"baseUrl": ".",
"paths": {
"@/*": ["src/*"]
}
},
"include": ["src"]
}

View file

@ -3759,6 +3759,11 @@ mixin-deep@^1.2.0:
for-in "^1.0.2"
is-extendable "^1.0.1"
module-alias@^2.2.2:
version "2.2.2"
resolved "https://registry.yarnpkg.com/module-alias/-/module-alias-2.2.2.tgz#151cdcecc24e25739ff0aa6e51e1c5716974c0e0"
integrity sha512-A/78XjoX2EmNvppVWEhM2oGk3x4lLxnkEA4jTbaK97QKSDjkIoOsKQlfylt/d3kKKi596Qy3NP5XrXJ6fZIC9Q==
ms@2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/ms/-/ms-2.0.0.tgz#5608aeadfc00be6c2901df5f9861788de0d597c8"