fix: re parsing env into config when swissoid-back and express-knifey already handle it
parent
7ac5348ecf
commit
b2dd5a35eb
@ -1,36 +0,0 @@
|
||||
import { isMeantToBeTrue, UnknownEnv } from 'swiss-army-knifey';
|
||||
|
||||
type Env = UnknownEnv & {
|
||||
APPLICATION_NAME?: string;
|
||||
APP_PORT?: string;
|
||||
NODE_ENV?: string;
|
||||
CORS_ALLOWED_ORIGIN?: string;
|
||||
CORS_CREDENTIALS?: string;
|
||||
COOKIE_DOMAIN?: string;
|
||||
SECURE_COOKIES?: string;
|
||||
TRUST_PROXY?: string;
|
||||
};
|
||||
|
||||
const appConfigMap = (env: Env) => ({
|
||||
applicationName: env.APPLICATION_NAME || 'Playchoo Auth',
|
||||
serverPort: (env.APP_PORT !== undefined && parseInt(env.APP_PORT, 10)) || 3700,
|
||||
nodeEnv: env.NODE_ENV || 'development',
|
||||
|
||||
corsAllowedOrigin: env.CORS_ALLOWED_ORIGIN || 'http://localhost:3000',
|
||||
corsCredentials:
|
||||
env.CORS_CREDENTIALS !== undefined
|
||||
? isMeantToBeTrue(env.CORS_CREDENTIALS)
|
||||
: true,
|
||||
|
||||
cookieDomain: env.COOKIE_DOMAIN,
|
||||
secureCookies:
|
||||
env.SECURE_COOKIES !== undefined
|
||||
? isMeantToBeTrue(env.SECURE_COOKIES)
|
||||
: env.NODE_ENV === 'production',
|
||||
|
||||
trustProxy: env.TRUST_PROXY || '1',
|
||||
healthCheckPath: '/healthz',
|
||||
healthCheckResponse: 'ok',
|
||||
});
|
||||
|
||||
export default appConfigMap;
|
||||
@ -1,30 +1,11 @@
|
||||
import 'dotenv/config';
|
||||
import DiContainer from 'di-why/build/src/DiContainer';
|
||||
import appConfigMap from './config/appConfigMap';
|
||||
import { loadDict } from './loaders';
|
||||
|
||||
async function bootstrap() {
|
||||
console.log('[Bootstrap] Starting Playchoo Auth Service...');
|
||||
|
||||
// Create DI container with all loaders
|
||||
const diContainer = new DiContainer({
|
||||
load: {
|
||||
...loadDict,
|
||||
// Override appConfig with our custom config
|
||||
appConfig: {
|
||||
factory: () => appConfigMap(process.env),
|
||||
locateDeps: {},
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
// Start the Express server (includes all middleware, OIDC routes, health checks)
|
||||
await diContainer.load('expressLauncher');
|
||||
|
||||
console.log('[Bootstrap] Playchoo Auth Service started successfully');
|
||||
}
|
||||
|
||||
bootstrap().catch((error) => {
|
||||
console.error('[Bootstrap] Failed to start Playchoo Auth Service:', error);
|
||||
process.exit(1);
|
||||
});
|
||||
import di from './loaders';
|
||||
|
||||
(async () => {
|
||||
try {
|
||||
await di.load('expressLauncher');
|
||||
} catch (err) {
|
||||
console.error('Failed to launch Express', err);
|
||||
process.exit(1);
|
||||
}
|
||||
})();
|
||||
Loading…
Reference in New Issue