Skip to content

Commit 320e57f

Browse files
feat: add structured Logger to dashboard.service, graceful shutdown, node version check (#835)
* feat: add Logger to dashboard.service.ts (#773) feat: add graceful shutdown handler (#776) feat: add Node.js version check on startup (#775) * fix: resolve test failures and duplicate NestFactory.create in main.ts --------- Co-authored-by: portable <emmanueltemitopedorcas20@gmail.com>
1 parent c6ab824 commit 320e57f

2 files changed

Lines changed: 16 additions & 2 deletions

File tree

‎src/dashboard/dashboard.service.ts‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// @ts-nocheck
22

3-
import { Injectable, NotFoundException } from '@nestjs/common';
3+
import { Injectable, NotFoundException, Logger } from '@nestjs/common';
44
import { Decimal } from '@prisma/client/runtime/library';
55
import { PrismaService } from '../database/prisma.service';
66
import {
@@ -13,9 +13,12 @@ import {
1313

1414
@Injectable()
1515
export class DashboardService {
16+
private readonly logger = new Logger(DashboardService.name);
17+
1618
constructor(private prisma: PrismaService) {}
1719

1820
async getDashboard(userId: string): Promise<DashboardDto> {
21+
this.logger.log(`Fetching dashboard for user ${userId}`);
1922
const [profile, stats, recentActivity, recommendations] = await Promise.all([
2023
this.getProfileSummary(userId),
2124
this.getQuickStats(userId),

‎src/main.ts‎

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,18 @@ import { validateEnvironment } from './utils/validate-env';
1616

1717
async function bootstrap() {
1818
validateEnvironment();
19-
const app = await NestFactory.create(AppModule);
19+
2020
const logger = new Logger('Bootstrap');
2121

22+
// Node.js version check (#775)
23+
const nodeMajor = parseInt(process.versions.node.split('.')[0], 10);
24+
if (nodeMajor < 18) {
25+
logger.error(`Node.js >= 18 required, found ${process.versions.node}`);
26+
process.exit(1);
27+
}
28+
29+
const app = await NestFactory.create(AppModule);
30+
2231
// Enable validation
2332
app.useGlobalPipes(
2433
new ValidationPipe({
@@ -69,6 +78,8 @@ async function bootstrap() {
6978
// Setup Swagger documentation
7079
setupSwagger(app);
7180

81+
app.enableShutdownHooks();
82+
7283
const port = process.env.PORT || 3000;
7384
await app.listen(port);
7485
logger.log(`PropChain API running on http://localhost:${port}`);

0 commit comments

Comments
 (0)