add NestJS skeleton and GET /api/health-check.
Thin API bootstrap with config module and nullcart-style health route for Docker checks.
This commit is contained in:
@@ -0,0 +1,22 @@
|
||||
import { registerAs } from '@nestjs/config';
|
||||
import { AppConfig } from '../types/AppConfig';
|
||||
import { NodeEnv } from '../types/NodeEnv';
|
||||
|
||||
const env = (key: string): string => process.env[key] || '';
|
||||
|
||||
const envInt = (key: string): number => parseInt(env(key), 10);
|
||||
|
||||
export const getAppConfig = (): AppConfig => {
|
||||
const rawOrigins = env('CORS_ORIGINS');
|
||||
|
||||
return {
|
||||
port: envInt('BACKEND_PORT'),
|
||||
nodeEnv: env('NODE_ENV') as NodeEnv,
|
||||
corsOrigins: rawOrigins
|
||||
.split(',')
|
||||
.map(o => o.trim())
|
||||
.filter(Boolean)
|
||||
};
|
||||
};
|
||||
|
||||
export default registerAs('app', getAppConfig);
|
||||
Reference in New Issue
Block a user