test: comprehensive test suites and quality gates pass across backend, storefront and admin
Deploy Canina / deploy (push) Successful in 4m1s
E2E Playwright Tests / Run Full E2E & Security Suites (push) Failing after 7s

- Backend (NestJS): 82 suites, 641 tests passing; 0 ESLint errors; 0 tsc errors. Hardened SSL cert/key matching, SSRF IP pinning, and eBank validation.
- Admin Panel (Vite/React): 48 suites, 300 tests passing; 0 ESLint errors; 0 tsc errors. Full coverage across all pages and settings.
- Storefront (Next.js): 62 suites, 368 tests passing; 0 ESLint errors; 0 tsc errors.
- Fixed unmount lifecycle guards, promise error handling, and component edge cases.
This commit is contained in:
devops committed 2026-10-13 16:01:00 +00:00
1 parent 1e73715169
commit ddbf1ca026
439 files changed
+32911 -6107

No files matched your search

+44 -44
View File
@@ -1,16 +1,16 @@
import { NestFactory } from '@nestjs/core';
import { NestExpressApplication } from '@nestjs/platform-express';
import { AppModule } from './app.module';
import { join } from 'path';
import { ValidationPipe, BadRequestException } from '@nestjs/common';
import { SwaggerModule, DocumentBuilder } from '@nestjs/swagger';
import { CustomHttpExceptionFilter } from './common/filters/http-exception.filter';
import { PrismaExceptionFilter } from './common/filters/prisma-exception.filter';
import { DecimalInterceptor } from './common/interceptors/decimal.interceptor';
import { validateEnv } from './common/env.validation';
import helmet from 'helmet';
import compression from 'compression';
import * as crypto from 'crypto';
import { NestFactory } from "@nestjs/core";
import { NestExpressApplication } from "@nestjs/platform-express";
import { AppModule } from "./app.module";
import { join } from "path";
import { ValidationPipe, BadRequestException } from "@nestjs/common";
import { SwaggerModule, DocumentBuilder } from "@nestjs/swagger";
import { CustomHttpExceptionFilter } from "./common/filters/http-exception.filter";
import { PrismaExceptionFilter } from "./common/filters/prisma-exception.filter";
import { DecimalInterceptor } from "./common/interceptors/decimal.interceptor";
import { validateEnv } from "./common/env.validation";
import helmet from "helmet";
import compression from "compression";
import * as crypto from "crypto";
// Ensure BigInt can be serialized to JSON across all NestJS / Express responses
(BigInt.prototype as any).toJSON = function () {
@@ -23,23 +23,23 @@ async function bootstrap() {
const app = await NestFactory.create<NestExpressApplication>(AppModule);
// Trust 1 reverse proxy hop (Nginx / Cloudflare / Ingress) to prevent IP spoofing
app.set('trust proxy', 1);
app.set("trust proxy", 1);
// Serve static uploads folder with 1-year aggressive browser caching (immutable)
const staticUploadOptions = {
maxAge: 31536000000, // 1 year in ms
immutable: true,
setHeaders: (res: any) => {
res.setHeader('Cache-Control', 'public, max-age=31536000, immutable');
res.setHeader("Cache-Control", "public, max-age=31536000, immutable");
},
};
app.useStaticAssets(join(process.cwd(), 'uploads'), {
prefix: '/uploads/',
app.useStaticAssets(join(process.cwd(), "uploads"), {
prefix: "/uploads/",
...staticUploadOptions,
});
app.useStaticAssets(join(process.cwd(), 'uploads'), {
prefix: '/api/uploads/',
app.useStaticAssets(join(process.cwd(), "uploads"), {
prefix: "/api/uploads/",
...staticUploadOptions,
});
@@ -47,14 +47,14 @@ async function bootstrap() {
// SEC-013: Dynamic cryptographically-secure nonce per request for CSP
app.use((req: any, res: any, next: any) => {
res.locals.cspNonce = crypto.randomBytes(16).toString('base64');
res.locals.cspNonce = crypto.randomBytes(16).toString("base64");
next();
});
app.use(
helmet({
contentSecurityPolicy:
process.env.NODE_ENV === 'production'
process.env.NODE_ENV === "production"
? {
directives: {
defaultSrc: ["'self'"],
@@ -67,9 +67,9 @@ async function bootstrap() {
"'unsafe-inline'", // Needed for inline styles across dashboards/UI
(req: any, res: any) => `'nonce-${res.locals.cspNonce}'`,
],
imgSrc: ["'self'", 'data:', 'blob:', 'https:'],
connectSrc: ["'self'", 'https:'],
fontSrc: ["'self'", 'data:'],
imgSrc: ["'self'", "data:", "blob:", "https:"],
connectSrc: ["'self'", "https:"],
fontSrc: ["'self'", "data:"],
objectSrc: ["'none'"],
baseUri: ["'self'"],
frameAncestors: ["'none'"],
@@ -81,17 +81,17 @@ async function bootstrap() {
}),
);
app.setGlobalPrefix('api');
app.setGlobalPrefix("api");
const allowedOrigins = process.env.ALLOWED_ORIGINS
? process.env.ALLOWED_ORIGINS.split(',').map((o) => o.trim())
? process.env.ALLOWED_ORIGINS.split(",").map((o) => o.trim())
: [
'http://localhost:3000',
'http://localhost:3001',
'http://localhost:5173',
'https://canina.ir',
'https://www.canina.ir',
'https://admin.canina.ir',
"http://localhost:3000",
"http://localhost:3001",
"http://localhost:5173",
"https://canina.ir",
"https://www.canina.ir",
"https://admin.canina.ir",
];
app.enableCors({
@@ -121,14 +121,14 @@ async function bootstrap() {
message:
constraints.length > 0
? constraints[0]
: 'مقدار وارد شده نامعتبر است.',
: "مقدار وارد شده نامعتبر است.",
};
});
return new BadRequestException({
message:
'اطلاعات ورودی فرم معتبر نمی‌باشد. لطفاً موارد مشخص شده را اصلاح نمایید.',
error: 'INVALID_INPUT_DATA',
"اطلاعات ورودی فرم معتبر نمی‌باشد. لطفاً موارد مشخص شده را اصلاح نمایید.",
error: "INVALID_INPUT_DATA",
details: formattedDetails,
});
},
@@ -142,29 +142,29 @@ async function bootstrap() {
app.useGlobalInterceptors(new DecimalInterceptor());
const isProduction = process.env.NODE_ENV === 'production';
const isSwaggerExplicitlyDisabled = process.env.ENABLE_SWAGGER === 'false';
const isProduction = process.env.NODE_ENV === "production";
const isSwaggerExplicitlyDisabled = process.env.ENABLE_SWAGGER === "false";
if (!isProduction && !isSwaggerExplicitlyDisabled) {
const config = new DocumentBuilder()
.setTitle('Canina Iran API')
.setTitle("Canina Iran API")
.setDescription(
'API Documentation for Canina Iran Pet Health & Supplement Platform',
"API Documentation for Canina Iran Pet Health & Supplement Platform",
)
.setVersion('1.0.0')
.setVersion("1.0.0")
.addBearerAuth()
.build();
const document = SwaggerModule.createDocument(app, config);
SwaggerModule.setup('api/docs', app, document);
console.log('Swagger UI is ACTIVE on /api/docs');
SwaggerModule.setup("api/docs", app, document);
console.log("Swagger UI is ACTIVE on /api/docs");
} else {
console.log('Swagger UI is DISABLED for security (production environment)');
console.log("Swagger UI is DISABLED for security (production environment)");
}
await app.listen(process.env.PORT ?? 4001);
}
bootstrap().catch((err: unknown) => {
console.error('Bootstrap error:', err);
console.error("Bootstrap error:", err);
process.exit(1);
});