Files
smart-project/server/package.json
jesxion 420d160421 feat: implement authentication with JWT and project context
- Add AuthUser type with id, username, role, and project_id
- Implement signAuthToken/verifyAuthToken with JWT (7d expiry)
- Add password hashing/verification with bcryptjs
- Create findUserByUsername repository function
- Add requireAuth middleware for Bearer token validation
- Add getProjectId helper to extract project_id from req.auth
- Implement POST /v1/auth/login route with Zod validation
- Wire auth router into Express app
- Add comprehensive auth tests (login success/failure cases)
- Install dependencies: jsonwebtoken, bcryptjs, dotenv

Tests passing: 4/4

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-04-24 10:58:57 +08:00

32 lines
722 B
JSON

{
"name": "smart-project-server",
"version": "1.0.0",
"type": "module",
"scripts": {
"dev": "tsx watch src/index.ts",
"build": "tsc",
"start": "node dist/index.js",
"test": "vitest run"
},
"dependencies": {
"bcryptjs": "^3.0.3",
"dotenv": "^17.4.2",
"express": "^4.18.2",
"jsonwebtoken": "^9.0.3",
"mysql2": "^3.22.2",
"zod": "^4.3.6"
},
"devDependencies": {
"@types/bcryptjs": "^2.4.6",
"@types/express": "^4.17.21",
"@types/jsonwebtoken": "^9.0.10",
"@types/mysql": "^2.15.27",
"@types/node": "^20.10.5",
"@types/supertest": "^6.0.2",
"supertest": "^6.3.3",
"tsx": "^4.7.0",
"typescript": "^5.3.3",
"vitest": "^1.1.0"
}
}