Skip to content

Commit

Permalink
feat: winton overwatch
Browse files Browse the repository at this point in the history
  • Loading branch information
Sampiiiii committed Apr 25, 2024
1 parent 1e89baa commit 62e8525
Show file tree
Hide file tree
Showing 4 changed files with 61 additions and 3 deletions.
2 changes: 2 additions & 0 deletions apps/anvil/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,8 @@
"tailwindcss": "^3.4.3",
"tough-cookie": "^4.1.3",
"typescript-memoize": "^1.1.1",
"winston": "^3.13.0",
"winston-daily-rotate-file": "^5.0.0",
"zod": "^3.22.4"
},
"devDependencies": {
Expand Down
3 changes: 2 additions & 1 deletion apps/anvil/src/app.module.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { EdgeDBModule } from "@/edgedb/edgedb.module";
import { TrainingService } from "@/training/training.service";
import { BullModule } from "@nestjs/bull";
import { Module } from "@nestjs/common";
import { Logger, Module } from "@nestjs/common";
import { ConfigModule } from "@nestjs/config";
import { APP_PIPE } from "@nestjs/core";
import { ScheduleModule } from "@nestjs/schedule";
Expand Down Expand Up @@ -59,6 +59,7 @@ import { UsersModule } from "./users/users.module";
EmailService,
RootService,
GoogleService,
Logger,
],
controllers: [SignInController, RootController, TrainingController],
})
Expand Down
27 changes: 25 additions & 2 deletions apps/anvil/src/main.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
import { ValidationPipe, VersioningType } from "@nestjs/common";
import { NestFactory } from "@nestjs/core";
import { DocumentBuilder, SwaggerModule } from "@nestjs/swagger";
import { WINSTON_MODULE_NEST_PROVIDER, WinstonModule } from "nest-winston";
import * as cookieParser from "cookie-parser";
import helmet from "helmet";
import { AppModule } from "./app.module";

import type { users } from "@ignis/types";
import * as Express from "express";
import * as winston from "winston";
import "winston-daily-rotate-file";
import { utilities as nestWinstonModuleUtilities } from "nest-winston/dist/winston.utilities";

declare global {
// biome-ignore lint/suspicious/noRedeclare: <explanation>
Expand All @@ -16,7 +20,27 @@ declare global {
}

async function bootstrap() {
const app = await NestFactory.create(AppModule);
// Setup Logger
const instance = winston.createLogger({
transports: [
new winston.transports.Console({
format: winston.format.combine(winston.format.timestamp(), nestWinstonModuleUtilities.format.nestLike()),
}),
new winston.transports.DailyRotateFile({
filename: "logs/anvil-%DATE%.log",
datePattern: "YYYY-MM-DD",
zippedArchive: true,
maxSize: "20m",
maxFiles: "14d",
format: winston.format.combine(winston.format.timestamp(), winston.format.json()),
}),
],
});
const app = await NestFactory.create(AppModule, {
logger: WinstonModule.createLogger({
instance,
}),
});
app.enableShutdownHooks();
app.enableCors({
origin: process.env.FRONT_END_URL as string,
Expand All @@ -41,7 +65,6 @@ async function bootstrap() {

const document = SwaggerModule.createDocument(app, options);
SwaggerModule.setup("api", app, document);

await app.listen(process.env.ANVIL_PORT || 3000);
}

Expand Down
32 changes: 32 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 62e8525

Please sign in to comment.