update config

This commit is contained in:
2026-06-16 10:09:22 +03:30
parent ac2e7f5dab
commit 652177862d
4 changed files with 32 additions and 21 deletions
+5 -1
View File
@@ -9,9 +9,13 @@ const adapter = new PrismaMariaDb({
user: env('DATABASE_USER'), user: env('DATABASE_USER'),
password: env('DATABASE_PASSWORD'), password: env('DATABASE_PASSWORD'),
database: env('DATABASE_NAME'), database: env('DATABASE_NAME'),
ssl: false,
connectionLimit: 5, connectionLimit: 5,
port: Number(env('DATABASE_PORT')) || 3306, port: Number(env('DATABASE_PORT')) || 3306,
allowPublicKeyRetrieval: true,
ssl: {
rejectUnauthorized: false,
},
connectTimeout: 10000,
}) })
const prisma = new PrismaClient({ adapter }) const prisma = new PrismaClient({ adapter })
+18 -19
View File
@@ -33,6 +33,7 @@ async function bootstrap() {
in: 'header', in: 'header',
}) })
.build() .build()
const documentFactory = () => SwaggerModule.createDocument(app, config) const documentFactory = () => SwaggerModule.createDocument(app, config)
SwaggerModule.setup('swagger', app, documentFactory, { SwaggerModule.setup('swagger', app, documentFactory, {
swaggerOptions: { swaggerOptions: {
@@ -47,14 +48,12 @@ async function bootstrap() {
}, },
}, },
}) })
// Set API prefix and enable URI versioning so alls routes live under /api/v1/* // Set API prefix and enable URI versioning so alls routes live under /api/v1/*
app.setGlobalPrefix('api') app.setGlobalPrefix('api')
app.enableVersioning({ app.enableVersioning({
type: VersioningType.URI, type: VersioningType.URI,
defaultVersion: '1', defaultVersion: '1',
}) })
// Enable CORS. You can set `CORS_ORIGINS` to a comma-separated list of allowed origins. // 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. // Defaults include common localhost origins used by front-end dev servers.
const defaultOrigins: string[] = [] const defaultOrigins: string[] = []
@@ -83,25 +82,25 @@ async function bootstrap() {
} }
} }
// app.enableCors({ app.enableCors({
// origin: (origin, callback) => { origin: (origin, callback) => {
// if (!origin) { if (!origin) {
// callback(null, true) callback(null, true)
// return return
// } }
// if (isOriginAllowed(origin)) { if (isOriginAllowed(origin)) {
// callback(null, true) callback(null, true)
// return return
// } }
// callback(new Error('Not allowed by CORS'), false) callback(new Error('Not allowed by CORS'), false)
// }, },
// credentials: true, credentials: true,
// methods: 'GET,HEAD,PUT,PATCH,POST,DELETE,OPTIONS', methods: 'GET,HEAD,PUT,PATCH,POST,DELETE,OPTIONS',
// allowedHeaders: allowedHeaders:
// 'Content-Type, Accept, Authorization, X-Requested-With, X-CSRF-Token, pos_id', 'Content-Type, Accept, Authorization, X-Requested-With, X-CSRF-Token, pos_id',
// }) })
// Register global logging and response mapping interceptors // Register global logging and response mapping interceptors
app.useGlobalInterceptors(new LoggingInterceptor(), new ResponseMappingInterceptor()) app.useGlobalInterceptors(new LoggingInterceptor(), new ResponseMappingInterceptor())
@@ -1,10 +1,14 @@
import { RedisKeyMaker } from '@/common/utils' import { RedisKeyMaker } from '@/common/utils'
import { PosCacheInvalidationService } from '@/modules/pos/cache/pos-cache-invalidation.service'
import { RedisService } from '@/redis/redis.service' import { RedisService } from '@/redis/redis.service'
import { Injectable } from '@nestjs/common' import { Injectable } from '@nestjs/common'
@Injectable() @Injectable()
export class PartnersCacheInvalidationService { export class PartnersCacheInvalidationService {
constructor(private readonly redisService: RedisService) {} constructor(
private readonly redisService: RedisService,
private readonly PosCacheInvalidationService: PosCacheInvalidationService,
) {}
async invalidatePartnerSummary(partnerId: string): Promise<void> { async invalidatePartnerSummary(partnerId: string): Promise<void> {
await this.invalidatePartnersList() await this.invalidatePartnersList()
@@ -6,6 +6,10 @@ import { Injectable } from '@nestjs/common'
export class PosCacheInvalidationService { export class PosCacheInvalidationService {
constructor(private readonly redisService: RedisService) {} constructor(private readonly redisService: RedisService) {}
async invalidatePosInfo(posId: string): Promise<void> {
this.redisService.delete(PosKeyMaker.info(posId))
}
async invalidatePosMiddleware(token: string): Promise<void> { async invalidatePosMiddleware(token: string): Promise<void> {
this.redisService.delete(PosKeyMaker.middleware(token)) this.redisService.delete(PosKeyMaker.middleware(token))
} }