Enhance TypeScript configuration and logging setup
- Added "rootDir" to tsconfig.build.json for improved build structure. - Implemented dynamic import for fs/promises in nest-logger.config.ts to ensure compatibility in different environments and handle directory creation more robustly.
This commit is contained in:
parent
67c763016d
commit
807d37a729
@ -5,6 +5,7 @@
|
||||
"incremental": true,
|
||||
"tsBuildInfoFile": "./tsconfig.build.tsbuildinfo",
|
||||
"outDir": "./dist",
|
||||
"rootDir": "./src",
|
||||
"sourceMap": true,
|
||||
"declaration": false,
|
||||
"removeComments": true,
|
||||
|
||||
@ -1,7 +1,19 @@
|
||||
// Lightweight, framework-agnostic factory that returns an object compatible
|
||||
// with nestjs-pino's LoggerModule.forRoot({ pinoHttp: {...} }) shape without importing types.
|
||||
import { join } from "path";
|
||||
import { mkdir } from "fs/promises";
|
||||
|
||||
// Dynamic import for fs/promises - will be resolved at runtime
|
||||
async function getMkdir() {
|
||||
if (typeof window !== 'undefined' || typeof process === 'undefined') {
|
||||
return null;
|
||||
}
|
||||
try {
|
||||
const fs = await import("fs/promises");
|
||||
return fs.mkdir;
|
||||
} catch {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
export async function createNestPinoConfig(configService: {
|
||||
get<T = string>(key: string, defaultValue?: T): T;
|
||||
@ -11,10 +23,13 @@ export async function createNestPinoConfig(configService: {
|
||||
const appName = configService.get<string>("APP_NAME", "customer-portal-bff");
|
||||
|
||||
if (nodeEnv === "production") {
|
||||
try {
|
||||
await mkdir("logs", { recursive: true });
|
||||
} catch {
|
||||
// ignore
|
||||
const mkdir = await getMkdir();
|
||||
if (mkdir) {
|
||||
try {
|
||||
await mkdir("logs", { recursive: true });
|
||||
} catch {
|
||||
// ignore
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user