update pos consumer module
This commit is contained in:
+12
-4
@@ -6,13 +6,15 @@ import { AppModule } from './app.module'
|
||||
import { PrismaExceptionFilter } from './common/filters/prisma-exception.filter'
|
||||
import { ValidationExceptionFilter } from './common/filters/validation-exception.filter'
|
||||
import { JwtAuthGuard } from './common/guards/jwt-auth.guard'
|
||||
import { PosGuard } from './common/guards/pos.gaurd'
|
||||
import { LoggingInterceptor } from './common/interceptors/logging.interceptor'
|
||||
import { ResponseMappingInterceptor } from './common/interceptors/response-mapping.interceptor'
|
||||
import { PrismaService } from './prisma/prisma.service'
|
||||
const cookieParser = require('cookie-parser')
|
||||
|
||||
async function bootstrap() {
|
||||
const app = await NestFactory.create(AppModule)
|
||||
|
||||
const cookieParser = (await import('cookie-parser')).default
|
||||
app.use(cookieParser())
|
||||
|
||||
const config = new DocumentBuilder()
|
||||
@@ -53,18 +55,21 @@ async function bootstrap() {
|
||||
|
||||
// Enable CORS. You can set `CORS_ORIGINS` to a comma-separated list of allowed origins.
|
||||
// Defaults include common localhost origins used by front-end dev servers.
|
||||
const defaultOrigins = ['*', 'http://localhost:5000']
|
||||
const defaultOrigins = ['http://localhost:5000', 'http://127.0.0.1:5000']
|
||||
const envOrigins = process.env.CORS_ORIGINS
|
||||
? process.env.CORS_ORIGINS.split(',')
|
||||
.map(s => s.trim())
|
||||
.filter(Boolean)
|
||||
: []
|
||||
const allowedOrigins = envOrigins.length ? envOrigins : defaultOrigins
|
||||
const allowedOrigins = (envOrigins.length ? envOrigins : defaultOrigins).filter(
|
||||
origin => origin !== '*',
|
||||
)
|
||||
app.enableCors({
|
||||
origin: allowedOrigins,
|
||||
credentials: true,
|
||||
methods: 'GET,HEAD,PUT,PATCH,POST,DELETE,OPTIONS',
|
||||
allowedHeaders: 'Content-Type, Accept, Authorization, X-Requested-With, X-CSRF-Token',
|
||||
allowedHeaders:
|
||||
'Content-Type, Accept, Authorization, X-Requested-With, X-CSRF-Token, pos_id',
|
||||
})
|
||||
|
||||
// Register global logging and response mapping interceptors
|
||||
@@ -77,6 +82,9 @@ async function bootstrap() {
|
||||
app.useGlobalFilters(new ValidationExceptionFilter(), new PrismaExceptionFilter())
|
||||
|
||||
app.useGlobalGuards(new JwtAuthGuard(app.get(JwtService), app.get(Reflector)))
|
||||
app.useGlobalGuards(
|
||||
new PosGuard(app.get(JwtService), app.get(Reflector), app.get(PrismaService)),
|
||||
)
|
||||
|
||||
await app.listen(process.env.PORT ?? 5002)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user