A RESTful API for managing tasks and projects, built with TypeScript, Express, Prisma, and SQLite.
- User authentication and authorization with JWT
- Task management (CRUD operations)
- Project management (CRUD operations)
- Secure logout with token blacklisting
- Input validation with Zod
- Error handling middleware
- SQLite database with Prisma ORM
- Backend: Node.js, TypeScript, Express
- Database: SQLite with Prisma ORM
- Authentication: JWT (JSON Web Tokens)
- Validation: Zod
- Password Hashing: bcryptjs
- Node.js (v16 or higher)
- npm or pnpm
-
Clone the repository:
git clone <repository-url> cd task-management-api
-
Install dependencies:
npm install # or pnpm install -
Set up the database:
npx prisma migrate dev npx prisma generate
-
Start the development server:
npm run dev
The server will start on http://localhost:3000.
Create a .env file in the root directory with the following variables:
DATABASE_URL="file:./taskmanagement.db"
jwt_secret="your_jwt_secret_key"
JWT_SECRET="your_jwt_secret_key" # Used in utils/jwt.ts
JWT_EXPIRES_IN="1d"POST /users/register- Register a new userPOST /users/login- Login userPOST /users/logout- Logout user (requires auth)GET /users/:id- Get user profilePUT /users/:id- Update user profileDELETE /users/:id- Delete user profile
All task endpoints require authentication.
GET /tasks- Get all tasks for the authenticated userGET /tasks/:name- Get task by namePOST /tasks- Create a new taskPUT /tasks/:id- Update a taskDELETE /tasks/:id- Delete a task
All project endpoints require authentication.
GET /projects- Get all projects for the authenticated userGET /projects/:name- Get project by namePOST /projects- Create a new projectPUT /projects/:id- Update a projectDELETE /projects/:id- Delete a project
POST /users/register
Content-Type: application/json
{
"name": "John Doe",
"email": "john@example.com",
"password": "password123"
}POST /tasks
Authorization: Bearer <jwt-token>
Content-Type: application/json
{
"title": "Complete project",
"description": "Finish the API development",
"priority": "High",
"dueDate": "2025-12-31"
}- id: String (CUID)
- email: String (unique)
- password: String (hashed)
- name: String
- tasks: Task[]
- projects: Project[]
- createdAt: DateTime
- id: String (CUID)
- title: String
- description: String?
- status: String (TODO, IN_PROGRESS, DONE)
- dueDate: DateTime?
- priority: String (LOW, MEDIUM, HIGH)
- userId: String
- projectId: String?
- createdAt: DateTime
- updatedAt: DateTime
- id: String (CUID)
- name: String
- description: String?
- userId: String
- tasks: Task[]
- createdAt: DateTime
- updatedAt: DateTime
- id: String (CUID)
- token: String (unique)
- createdAt: DateTime
npm run dev- Start development server with nodemonnpm start- Build and start production servernpx prisma migrate dev- Run database migrationsnpx prisma generate- Generate Prisma clientnpx prisma studio- Open Prisma Studio for database management
src/
├── controllers/ # Route handlers
├── middleware/ # Express middleware
├── routes/ # API routes
├── schema/ # Zod validation schemas
├── types/ # TypeScript type definitions
├── utils/ # Utility functions
├── index.ts # Application entry point
└── server.ts # Server configuration
prisma/
├── schema.prisma # Database schema
└── migrations/ # Database migrations
- Fork the repository
- Create a feature branch
- Make your changes
- Run tests
- Submit a pull request
This project is licensed under the MIT License.