Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 | 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x | import { Inject } from '@nestjs/common';
import { registerAs, type ConfigType } from '@nestjs/config';
import * as env from 'env-var';
import { trimEnd } from 'lodash-es';
export const authConfig = registerAs('auth0', () => {
const isAuthEnabled = env.get('ENABLE_AUTH').default('true').asBool();
const baseUrl = `https://${trimEnd(env.get('AUTH0_ISSUER_URL').required(isAuthEnabled).asString(), '/')}`;
return {
baseUrl,
issuerUrl: `${baseUrl}/`,
audience: env.get('AUTH0_AUDIENCE').required(isAuthEnabled).asString(),
authorizationUrl: `${baseUrl}/authorize`,
tokenUrl: `${baseUrl}/oauth/token`,
userInfoUrl: `${baseUrl}/userinfo`,
} as const;
});
const AUTH_CONFIG = authConfig.KEY;
export const InjectAuthConfig = () => Inject(AUTH_CONFIG);
export type AuthConfig = ConfigType<typeof authConfig>;
|