A backend API for an ERP-style task management system built with Node.js, Express.js, TypeScript, Prisma ORM, and PostgreSQL. Features include user authentication, RBAC, task CRUD, status management, logging, and more.
- User registration (admin-only)
- JWT authentication
- Role-based access control (RBAC)
- Full CRUD for tasks
- Task assignment (admin-only)
- Status management with allowed transitions
- Action logging to database
src/
controllers/
middlewares/
prisma/
routes/
services/
types/
utils/
git clone <repo-url>
cd <project-folder>
npm install
Create a .env file in the root directory:
DATABASE_URL="postgresql://*****@localhost:5432/task_db?schema=public"
JWT_SECRET="*****"
PORT=****
- Ensure PostgreSQL is running and the database
task_dbexists. - Run Prisma migrations:
npx prisma migrate dev --name init
npx prisma generate
npm run dev
See the exported Postman collection for all endpoints and example requests.
POST /auth/login— User loginPOST /users— Register user (admin-only)GET /tasks— List all tasks (admin-only)POST /tasks— Create task (admin-only)PUT /tasks/:id— Update task (with status management)DELETE /tasks/:id— Delete task (admin-only)POST /tasks/:id/assign— Assign task (admin-only)
- Allows admins to register users and assign tasks
- Team members can update and complete their assigned tasks
- All actions are logged in the database
- Status transitions are strictly enforced
- All endpoints require JWT authentication except login
- RBAC is enforced for sensitive actions
- Logs are stored in the
Logtable