Backend Features:
- Timesheets database table (id, userId, fileName, filePath, fileType, fileSize, year, month, timestamps)
- File upload with multer (memory storage, 10MB limit, PDF/Excel validation)
- Structured file storage: uploads/timesheets/{userId}/{year}/{month}/
- RESTful API endpoints:
* POST /api/timesheets/upload - Upload timesheet
* GET /api/timesheets/my - Get user's timesheets (with filters)
* GET /api/timesheets/all - Get all timesheets (admin only)
* GET /api/timesheets/:id/download - Download file
* DELETE /api/timesheets/:id - Delete timesheet
- Role-based permissions: users access own files, admins access all
- Proper error handling and file cleanup on errors
- Database migration for timesheets table
Technical:
- Uses req.user.role for permission checks
- Automatic directory creation for user/year/month structure
- Blob URL cleanup and proper file handling
- Integration with existing auth middleware
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
55 lines
1.4 KiB
JSON
55 lines
1.4 KiB
JSON
{
|
|
"name": "crm-server",
|
|
"version": "1.0.0",
|
|
"description": "basic express api backend",
|
|
"main": "src/index.js",
|
|
"scripts": {
|
|
"dev": "nodemon src/index.js",
|
|
"start": "node src/index.js",
|
|
"test": "node --experimental-vm-modules node_modules/.bin/jest",
|
|
"db:generate": "drizzle-kit generate",
|
|
"db:migrate": "node src/db/migrate.js",
|
|
"db:push": "drizzle-kit push",
|
|
"db:studio": "drizzle-kit studio",
|
|
"db:seed": "node src/db/seeds/admin.seed.js",
|
|
"db:seed:testuser": "node src/db/seeds/testuser.seed.js"
|
|
},
|
|
"keywords": [],
|
|
"author": "Richard Tekula",
|
|
"license": "MIT",
|
|
"dependencies": {
|
|
"axios": "^1.13.2",
|
|
"bcryptjs": "^3.0.3",
|
|
"better-auth": "^1.3.34",
|
|
"cookie-parser": "^1.4.7",
|
|
"cors": "^2.8.5",
|
|
"dotenv": "^16.4.5",
|
|
"drizzle-orm": "^0.44.7",
|
|
"express": "^4.21.1",
|
|
"express-rate-limit": "^8.2.1",
|
|
"helmet": "^8.0.0",
|
|
"jsonwebtoken": "^9.0.2",
|
|
"morgan": "^1.10.0",
|
|
"multer": "^2.0.2",
|
|
"pg": "^8.16.3",
|
|
"uuid": "^13.0.0",
|
|
"xss-clean": "^0.1.4",
|
|
"zod": "^4.1.12"
|
|
},
|
|
"devDependencies": {
|
|
"@types/bcryptjs": "^2.4.6",
|
|
"@types/jsonwebtoken": "^9.0.10",
|
|
"@types/pg": "^8.15.6",
|
|
"drizzle-kit": "^0.31.7",
|
|
"eslint": "latest",
|
|
"jest": "^29.7.0",
|
|
"nodemon": "^3.1.7",
|
|
"supertest": "^6.3.4"
|
|
},
|
|
"type": "module",
|
|
"jest": {
|
|
"testEnvironment": "node",
|
|
"transform": {}
|
|
}
|
|
}
|