Skip to content

Commit

Permalink
Update cd.yml
Browse files Browse the repository at this point in the history
  • Loading branch information
JuribaDev committed Aug 31, 2024
1 parent f537b9e commit 4ba1985
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 1 deletion.
9 changes: 9 additions & 0 deletions apps/server/src/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,13 @@ import { MongooseModule } from '@nestjs/mongoose';
import { AuthModule } from './auth/auth.module';
import { ProductModule } from './product/product.module';
import { EventEmitterModule } from '@nestjs/event-emitter';
import { ThrottlerGuard, ThrottlerModule } from '@nestjs/throttler';
import { APP_GUARD } from '@nestjs/core';

@Module({
imports: [
EventEmitterModule.forRoot(),
ThrottlerModule.forRoot([{ ttl: 60000, limit: 100 }]),
ConfigModule.forRoot({
isGlobal: true,
envFilePath: '.env',
Expand Down Expand Up @@ -36,5 +39,11 @@ import { EventEmitterModule } from '@nestjs/event-emitter';
AuthModule,
ProductModule,
],
providers: [
{
provide: APP_GUARD,
useClass: ThrottlerGuard,
},
]
})
export class AppModule {}
10 changes: 9 additions & 1 deletion apps/server/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@ import { NestFactory } from '@nestjs/core';

import { AppModule } from './app.module';
import mongoose from 'mongoose';
import { ORIGINS } from './shared/origins';

async function bootstrap() {
const app = await NestFactory.create(AppModule);
const app = await NestFactory.create(AppModule, {logger: ['error', 'warn', 'log','fatal']});
app.useGlobalPipes(new ValidationPipe({
whitelist: true,
forbidNonWhitelisted: true,
Expand All @@ -19,6 +20,13 @@ async function bootstrap() {
return new BadRequestException(result);
},
}));
app.enableCors({
origin: ORIGINS,
methods: ['GET', 'POST', 'PUT', 'DELETE', 'PATCH', 'OPTIONS'],
allowedHeaders: ['Content-Type', 'Authorization'],
credentials: true,
});

const globalPrefix = 'api/v1';
app.setGlobalPrefix(globalPrefix);

Expand Down
5 changes: 5 additions & 0 deletions apps/server/src/shared/origins.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
export const ORIGINS = [
"https://34.1.32.26",
"https://rnd-platform-client-app-p5qzcycuqa-ww.a.run.app",
"http://localhost",
]
12 changes: 12 additions & 0 deletions package-lock.json

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

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
"@nestjs/passport": "^10.0.3",
"@nestjs/platform-express": "^10.0.2",
"@nestjs/terminus": "^10.2.3",
"@nestjs/throttler": "^6.2.1",
"@ngrx/component-store": "^18.0.2",
"@ngrx/effects": "^18.0.2",
"@ngrx/entity": "^18.0.2",
Expand Down

0 comments on commit 4ba1985

Please sign in to comment.