-
Notifications
You must be signed in to change notification settings - Fork 12
Expand file tree
/
Copy pathmain.ts
More file actions
23 lines (19 loc) · 844 Bytes
/
main.ts
File metadata and controls
23 lines (19 loc) · 844 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
import 'dotenv/config';
import { NestFactory } from '@nestjs/core';
import { ValidationPipe } from '@nestjs/common';
import { AppModule } from './app.module';
import { ApiKeyGuard } from './common/guards/api-key.guard';
(BigInt.prototype as any).toJSON = function () { return this.toString(); };
async function bootstrap() {
const app = await NestFactory.create(AppModule);
app.enableCors({
origin: ['http://localhost:3000', 'http://localhost:3001'],
methods: ['GET', 'POST', 'PUT', 'PATCH', 'DELETE', 'OPTIONS'],
allowedHeaders: ['Content-Type', 'Authorization', 'x-api-key'],
});
app.useGlobalPipes(new ValidationPipe({ whitelist: true }));
app.useGlobalGuards(new ApiKeyGuard());
await app.listen(process.env.PORT ?? 4000);
console.log(`Core API is running on port ${process.env.PORT ?? 4000}`);
}
bootstrap();