Refactor CORS configuration and add utility, update package.json for dev start command, and create GraphQL query/mutation files
This commit is contained in:
3
.vscode/settings.json
vendored
Normal file
3
.vscode/settings.json
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"dependi.npm.lockFileEnabled": false
|
||||
}
|
||||
@@ -19,4 +19,4 @@ services:
|
||||
networks:
|
||||
epess-net:
|
||||
driver: bridge
|
||||
external: true
|
||||
external: true
|
||||
@@ -9,7 +9,7 @@
|
||||
"build": "nest build",
|
||||
"format": "prettier --write \"src/**/*.ts\" \"test/**/*.ts\"",
|
||||
"start": "nest start",
|
||||
"start:dev": "nest start --watch",
|
||||
"start:dev": "npm run prisma:generate && nest start --watch",
|
||||
"start:debug": "nest start --debug --watch",
|
||||
"start:prod": "node dist/main",
|
||||
"prisma:generate": "npx prisma generate --schema=./epess-database/prisma/schema.prisma",
|
||||
|
||||
6
src/common/utils/cors.utils.ts
Normal file
6
src/common/utils/cors.utils.ts
Normal file
@@ -0,0 +1,6 @@
|
||||
export const cors = {
|
||||
origin: process.env.CORS_ORIGIN,
|
||||
methods: ['GET', 'POST', 'PUT', 'DELETE', 'PATCH', 'OPTIONS'],
|
||||
allowedHeaders: ['Content-Type', 'Authorization'],
|
||||
credentials: true,
|
||||
};
|
||||
@@ -22,4 +22,4 @@ export class GraphqlModule {
|
||||
.apply(GraphQLValidationMiddleware) // Apply the custom middleware
|
||||
.forRoutes('graphql'); // Ensure it only applies to the /graphql endpoint
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
0
src/graphql/query.graphql.ts
Normal file
0
src/graphql/query.graphql.ts
Normal file
0
src/graphql/subscription.graphql.ts
Normal file
0
src/graphql/subscription.graphql.ts
Normal file
@@ -1,15 +1,10 @@
|
||||
import { NestFactory } from '@nestjs/core';
|
||||
import { AppModule } from './app.module';
|
||||
import { cors } from './common/utils/cors.utils';
|
||||
|
||||
async function bootstrap() {
|
||||
const app = await NestFactory.create(AppModule);
|
||||
app.enableCors({
|
||||
origin: '*',
|
||||
methods: 'GET,HEAD,PUT,PATCH,POST,DELETE',
|
||||
preflightContinue: false,
|
||||
optionsSuccessStatus: 204,
|
||||
credentials: true,
|
||||
});
|
||||
app.enableCors(cors);
|
||||
await app.listen(3000);
|
||||
}
|
||||
bootstrap();
|
||||
|
||||
Reference in New Issue
Block a user