- src/api/middleware/auth.ts: signToken, verifyToken, authMiddleware (Bearer JWT, 24h expiry) - src/api/routes/auth.ts: POST /api/auth/login (bcryptjs verify) and GET /api/auth/me (protected) - src/index.ts: mount auth router at /api/auth - tests/api/auth.test.ts: 7 tests covering login success, wrong password, no token, invalid token, valid access - Using bcryptjs (pure JS) instead of bcrypt (requires Visual Studio on Windows) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
38 lines
958 B
JSON
38 lines
958 B
JSON
{
|
|
"name": "display-middleware",
|
|
"version": "1.0.0",
|
|
"description": "Middleware backend for ESP32 e-paper display system",
|
|
"main": "dist/index.js",
|
|
"scripts": {
|
|
"dev": "tsx watch src/index.ts",
|
|
"build": "tsc",
|
|
"start": "node dist/index.js",
|
|
"test": "vitest run",
|
|
"test:watch": "vitest"
|
|
},
|
|
"dependencies": {
|
|
"bcryptjs": "^3.0.3",
|
|
"better-sqlite3": "^9.6.0",
|
|
"cors": "^2.8.6",
|
|
"express": "^4.22.1",
|
|
"jsonwebtoken": "^9.0.3",
|
|
"mqtt": "^5.15.1",
|
|
"node-sqlite3-wasm": "^0.8.55",
|
|
"pg": "^8.20.0"
|
|
},
|
|
"devDependencies": {
|
|
"@types/bcryptjs": "^2.4.6",
|
|
"@types/better-sqlite3": "^7.6.13",
|
|
"@types/cors": "^2.8.19",
|
|
"@types/express": "^4.17.25",
|
|
"@types/jsonwebtoken": "^9.0.10",
|
|
"@types/node": "^20.19.39",
|
|
"@types/pg": "^8.20.0",
|
|
"@types/supertest": "^6.0.3",
|
|
"supertest": "^6.3.4",
|
|
"tsx": "^4.21.0",
|
|
"typescript": "^5.9.3",
|
|
"vitest": "^1.6.1"
|
|
}
|
|
}
|