refactor: enhance security and performance in configuration and API routes

- Update Content Security Policy (CSP) in next.config.ts to avoid `unsafe-eval` in production, improving security against XSS attacks.
- Refactor API routes to enforce admin authentication and session validation, ensuring secure access to sensitive endpoints.
- Optimize analytics data retrieval by using database aggregation instead of loading all records into memory, improving performance and reducing memory usage.
- Implement session token creation and verification for better session management and security across the application.
- Enhance error handling and input validation in various API routes to ensure robustness and prevent potential issues.
This commit is contained in:
2026-01-11 22:44:26 +01:00
parent 9cc03bc475
commit 9072faae43
28 changed files with 433 additions and 288 deletions

View File

@@ -10,14 +10,14 @@
"db:seed": "tsx -r dotenv/config prisma/seed.ts dotenv_config_path=.env.local",
"build": "next build",
"start": "next start",
"lint": "eslint .",
"lint": "cross-env NODE_ENV=development eslint .",
"lint:fix": "eslint . --fix",
"pre-push": "./scripts/pre-push.sh",
"pre-push:full": "./scripts/pre-push-full.sh",
"pre-push:quick": "./scripts/pre-push-quick.sh",
"test:all": "npm run test && npm run test:e2e",
"buildAnalyze": "cross-env ANALYZE=true next build",
"test": "jest",
"test": "cross-env NODE_ENV=test jest",
"test:production": "NODE_ENV=production jest --config jest.config.production.ts",
"test:watch": "jest --watch",
"test:coverage": "jest --coverage",