update config
This commit is contained in:
+5
-1
@@ -9,9 +9,13 @@ const adapter = new PrismaMariaDb({
|
||||
user: env('DATABASE_USER'),
|
||||
password: env('DATABASE_PASSWORD'),
|
||||
database: env('DATABASE_NAME'),
|
||||
ssl: false,
|
||||
connectionLimit: 5,
|
||||
port: Number(env('DATABASE_PORT')) || 3306,
|
||||
allowPublicKeyRetrieval: true,
|
||||
ssl: {
|
||||
rejectUnauthorized: false,
|
||||
},
|
||||
connectTimeout: 10000,
|
||||
})
|
||||
|
||||
const prisma = new PrismaClient({ adapter })
|
||||
|
||||
+18
-19
@@ -33,6 +33,7 @@ async function bootstrap() {
|
||||
in: 'header',
|
||||
})
|
||||
.build()
|
||||
|
||||
const documentFactory = () => SwaggerModule.createDocument(app, config)
|
||||
SwaggerModule.setup('swagger', app, documentFactory, {
|
||||
swaggerOptions: {
|
||||
@@ -47,14 +48,12 @@ async function bootstrap() {
|
||||
},
|
||||
},
|
||||
})
|
||||
|
||||
// Set API prefix and enable URI versioning so alls routes live under /api/v1/*
|
||||
app.setGlobalPrefix('api')
|
||||
app.enableVersioning({
|
||||
type: VersioningType.URI,
|
||||
defaultVersion: '1',
|
||||
})
|
||||
|
||||
// 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: string[] = []
|
||||
@@ -83,25 +82,25 @@ async function bootstrap() {
|
||||
}
|
||||
}
|
||||
|
||||
// app.enableCors({
|
||||
// origin: (origin, callback) => {
|
||||
// if (!origin) {
|
||||
// callback(null, true)
|
||||
// return
|
||||
// }
|
||||
app.enableCors({
|
||||
origin: (origin, callback) => {
|
||||
if (!origin) {
|
||||
callback(null, true)
|
||||
return
|
||||
}
|
||||
|
||||
// if (isOriginAllowed(origin)) {
|
||||
// callback(null, true)
|
||||
// return
|
||||
// }
|
||||
if (isOriginAllowed(origin)) {
|
||||
callback(null, true)
|
||||
return
|
||||
}
|
||||
|
||||
// callback(new Error('Not allowed by CORS'), false)
|
||||
// },
|
||||
// credentials: true,
|
||||
// methods: 'GET,HEAD,PUT,PATCH,POST,DELETE,OPTIONS',
|
||||
// allowedHeaders:
|
||||
// 'Content-Type, Accept, Authorization, X-Requested-With, X-CSRF-Token, pos_id',
|
||||
// })
|
||||
callback(new Error('Not allowed by CORS'), false)
|
||||
},
|
||||
credentials: true,
|
||||
methods: 'GET,HEAD,PUT,PATCH,POST,DELETE,OPTIONS',
|
||||
allowedHeaders:
|
||||
'Content-Type, Accept, Authorization, X-Requested-With, X-CSRF-Token, pos_id',
|
||||
})
|
||||
|
||||
// Register global logging and response mapping interceptors
|
||||
app.useGlobalInterceptors(new LoggingInterceptor(), new ResponseMappingInterceptor())
|
||||
|
||||
@@ -1,10 +1,14 @@
|
||||
import { RedisKeyMaker } from '@/common/utils'
|
||||
import { PosCacheInvalidationService } from '@/modules/pos/cache/pos-cache-invalidation.service'
|
||||
import { RedisService } from '@/redis/redis.service'
|
||||
import { Injectable } from '@nestjs/common'
|
||||
|
||||
@Injectable()
|
||||
export class PartnersCacheInvalidationService {
|
||||
constructor(private readonly redisService: RedisService) {}
|
||||
constructor(
|
||||
private readonly redisService: RedisService,
|
||||
private readonly PosCacheInvalidationService: PosCacheInvalidationService,
|
||||
) {}
|
||||
|
||||
async invalidatePartnerSummary(partnerId: string): Promise<void> {
|
||||
await this.invalidatePartnersList()
|
||||
|
||||
@@ -6,6 +6,10 @@ import { Injectable } from '@nestjs/common'
|
||||
export class PosCacheInvalidationService {
|
||||
constructor(private readonly redisService: RedisService) {}
|
||||
|
||||
async invalidatePosInfo(posId: string): Promise<void> {
|
||||
this.redisService.delete(PosKeyMaker.info(posId))
|
||||
}
|
||||
|
||||
async invalidatePosMiddleware(token: string): Promise<void> {
|
||||
this.redisService.delete(PosKeyMaker.middleware(token))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user