change config redis db

This commit is contained in:
2026-03-29 17:32:57 +03:00
parent 7825acaa97
commit dcd170b595
4 changed files with 18 additions and 1 deletions

2
.env
View File

@@ -1,7 +1,7 @@
PORT=3000 PORT=3000
NODE_ENV=production NODE_ENV=production
DB_URL=postgres://parsdbshop:ZtKKAQWA00umtkNXUMcjVNRD6avXFOVDOfqGcTTLwhnGUYq6EnSvaYsyJi06sx6j@62.3.14.124:6986/postgres DB_URL=postgres://parsdbshop:ZtKKAQWA00umtkNXUMcjVNRD6avXFOVDOfqGcTTLwhnGUYq6EnSvaYsyJi06sx6j@62.3.14.124:6986/postgres
REDIS_URL=redis://parsuserdb:xTpObuam6vTAAtWhn92rvQdo8rjhO22K4IxyJxdooUAPoyY9zLbYSYBSRm6io7E6@62.3.14.124:9654/0 REDIS_URL=redis://parsuserdb:xTpObuam6vTAAtWhn92rvQdo8rjhO22K4IxyJxdooUAPoyY9zLbYSYBSRm6io7E6@agkcwogo044go0gocooc4kkg:6379/0
MINIO_ENDPOINT=s3.ir-thr-at1.arvanstorage.ir MINIO_ENDPOINT=s3.ir-thr-at1.arvanstorage.ir
MINIO_PORT=80 MINIO_PORT=80
MINIO_ACCESS_KEY=8e66af66-67cb-4dcb-ba62-36e88ad7083e MINIO_ACCESS_KEY=8e66af66-67cb-4dcb-ba62-36e88ad7083e

View File

@@ -2,6 +2,10 @@ export default () => ({
app: { app: {
port: parseInt(process.env.PORT ?? '3000', 10), port: parseInt(process.env.PORT ?? '3000', 10),
nodeEnv: process.env.NODE_ENV ?? 'development', nodeEnv: process.env.NODE_ENV ?? 'development',
corsOrigins: (process.env.CORS_ORIGINS ?? 'http://localhost:3000')
.split(',')
.map((origin) => origin.trim())
.filter(Boolean),
}, },
database: { database: {
url: process.env.DB_URL, url: process.env.DB_URL,

View File

@@ -10,6 +10,10 @@ class EnvironmentVariables {
@IsString() @IsString()
NODE_ENV?: string; NODE_ENV?: string;
@IsOptional()
@IsString()
CORS_ORIGINS?: string;
@IsNotEmpty() @IsNotEmpty()
@IsString() @IsString()
DB_URL!: string; DB_URL!: string;

View File

@@ -1,4 +1,5 @@
import { ValidationPipe } from '@nestjs/common'; import { ValidationPipe } from '@nestjs/common';
import { ConfigService } from '@nestjs/config';
import { NestFactory, Reflector } from '@nestjs/core'; import { NestFactory, Reflector } from '@nestjs/core';
import { DocumentBuilder, SwaggerModule } from '@nestjs/swagger'; import { DocumentBuilder, SwaggerModule } from '@nestjs/swagger';
import { AppModule } from './app.module'; import { AppModule } from './app.module';
@@ -7,8 +8,16 @@ import { ResponseInterceptor } from './common/interceptors/response.interceptor'
async function bootstrap() { async function bootstrap() {
const app = await NestFactory.create(AppModule); const app = await NestFactory.create(AppModule);
const reflector = app.get(Reflector); const reflector = app.get(Reflector);
const configService = app.get(ConfigService);
const corsOrigins = configService.get<string[]>('app.corsOrigins', []);
app.setGlobalPrefix('api'); app.setGlobalPrefix('api');
app.enableCors({
origin: corsOrigins,
credentials: true,
methods: ['GET', 'HEAD', 'PUT', 'PATCH', 'POST', 'DELETE', 'OPTIONS'],
allowedHeaders: ['Content-Type', 'Authorization', 'x-product-type'],
});
app.useGlobalPipes( app.useGlobalPipes(
new ValidationPipe({ new ValidationPipe({
whitelist: true, whitelist: true,