feat(iter-v2): T01 complete - security + infrastructure

- S1: .githooks/pre-commit blocks .env commits, .env.test in .gitignore
- S3: TOKEN_SECRET centralized to config/token.ts, all files import from it
- S3: checkTokenSecret enforces min 32-char TOKEN_SECRET at startup
- S5: Refresh Token mechanism (Access 2h + Refresh 30d, dual token)
- S5: POST /auth/refresh endpoint with rotation and max 5 per user
- S5: Frontend request.ts auto-refresh on 40101, concurrent-safe
- S6: Soft delete (deleted_at column), admin soft-delete with confirmName
- S6: POST /admin/users/:id/restore endpoint
- S6: All user queries filter deleted_at IS NULL
- S7: DB connection requires env vars, no fallback credentials
- Infra: jest.config.js, vitest.config.ts, .env.test
- Infra: node-cron, jest, ts-jest, supertest, vitest, @pinia/testing
This commit is contained in:
2026-06-11 09:24:10 +08:00
parent 61f9b33f8c
commit 263a7c4616
31 changed files with 8365 additions and 131 deletions

View File

@@ -6,7 +6,8 @@
"dev": "tsx watch src/index.ts",
"build": "tsc && shx cp src/db/*.sql dist/db/",
"start": "node dist/index.js",
"db:init": "tsx src/db/init.ts"
"db:init": "tsx src/db/init.ts",
"test": "jest"
},
"dependencies": {
"cors": "^2.8.5",
@@ -21,7 +22,11 @@
"@types/express": "^4.17.21",
"@types/multer": "^2.1.0",
"@types/node": "^20.11.0",
"@types/supertest": "^6.0.3",
"jest": "^29.7.0",
"shx": "^0.4.0",
"supertest": "^6.3.4",
"ts-jest": "^29.4.11",
"tsx": "^4.7.0",
"typescript": "^5.3.0"
}