This project is a task management API built using modern technologies to provide high performance and scalability:
- Cloudflare Workers
- Hono.js
- TypeScript
- Prisma ORM
- Prisma Accelerate
- PostgreSQL
- JWT Authentication
The combination of Cloudflare Workers and Prisma Accelerate offers significant benefits including global distribution, reduced latency, automatic scaling, and optimized database connections.
- Cloudflare Workers ensure lightning-fast performance and global availability.
- Hono.js provides an ultra-lightweight, Express-like developer experience.
- Prisma Accelerate optimizes database queries with edge caching and enhanced connection handling.
- Node.js (v16 or newer)
- PostgreSQL database
- Cloudflare account
- Prisma Accelerate account
-
Clone the repository and navigate to the backend directory:
git clone https://github.com/CallMeSahu/app-task-management.git cd app-task-management/backend -
Install dependencies:
npm install
-
Setup your PostgreSQL connection and Prisma Accelerate:
- Have your PostgreSQL connection URL ready
- Login to Prisma Accelerate
- Enable Prisma Accelerate for your PostgreSQL database
- Save the provided Prisma Accelerate proxy URL
-
Create a
.envfile:touch .env
-
Add the following content to
.env:DATABASE_URL="your_postgres_url" -
Create a
wrangler.tomlfile:touch wrangler.toml
-
Add the following content to
wrangler.toml:name = "app-task-management" compatibility_date = "2025-04-08" main = "src/index.ts" [vars] DATABASE_URL="your_prisma_accelerate_proxy_url" JWT_SECRET="your_jwt_secret"
-
Migrate your database:
npx prisma migrate dev --name init_schema
-
Generate Prisma client:
npx prisma generate --no-engine
-
Run the application locally:
npx wrangler dev
The API is deployed on Cloudflare Workers and accessible using the following link:
https://app-task-management.siddharthasahu-work.workers.dev
All endpoints except for registration and login require JWT authentication. Include the JWT token in the Authorization Header:
Authorization: Bearer <your_jwt_token>
- URL:
/api/v1/user/signup - Method:
POST - Auth Required: No
- Request Body:
{ "name": "Test Admin", "email": "test@test.com", "password": "Test@123" } - Response:
{ "token": "jwt_token_here" }
- URL:
/api/v1/user/signin - Method:
POST - Auth Required: No
- Request Body:
{ "email": "test@test.com", "password": "Test@123" } - Response:
{ "token": "jwt_token_here" }
- URL:
/api/v1/task - Method:
POST - Auth Required: Yes
- Request Body:
{ "title": "Complete project documentation", "description": "Write comprehensive README.md file", "status": "PENDING" } - Response:
{ "task": { "id": "86abf0af-a628-4aa1-8c97-8a6923b52513", "title": "Complete project documentation", "description": "Write comprehensive README.md file", "status": "PENDING", "userId": "379db18a-9efc-465d-aa2e-58bbc52ae587" } }
- URL:
/api/v1/task - Method:
GET - Auth Required: Yes
- Response:
{ "tasks": [ { "id": "86abf0af-a628-4aa1-8c97-8a6923b52513", "title": "Complete project documentation", "description": "Write comprehensive README.md file", "status": "PENDING", "userId": "379db18a-9efc-465d-aa2e-58bbc52ae587" }, { "id": "ca7aea8f-ceab-4201-a457-d5cf38d30091", "title": "Deploy application", "description": "Deploy the app to production environment", "status": "PENDING", "userId": "379db18a-9efc-465d-aa2e-58bbc52ae587" }, { "id": "8471bbfa-41fc-414e-a0c8-7d644a5722ad", "title": "Fix API bugs", "description": "Address error handling in authentication endpoints", "status": "COMPLETED", "userId": "379db18a-9efc-465d-aa2e-58bbc52ae587" } ] }
- URL:
/api/v1/task/:id - Method:
PUT - Auth Required: Yes
- Request Body:
{ "title": "Deploy application", "status": "COMPLETED" } - Response:
{ "task": { "id": "ca7aea8f-ceab-4201-a457-d5cf38d30091", "title": "Deploy the application", "description": "Deploy the app to production environment", "status": "COMPLETED", "userId": "379db18a-9efc-465d-aa2e-58bbc52ae587" } }
- URL:
/api/v1/task/:id - Method:
DELETE - Auth Required: Yes
- Response:
{ "message": "Task deleted successfully" }
You can access and import the Postman collection for testing this API using the following link:
Task Management API Postman Collection
The API is deployed on Cloudflare Workers, which provides edge computing capabilities for low-latency globally distributed access.
-
Authenticate with Cloudflare:
npx wrangler login
-
Deploy the application:
npx wrangler deploy
-
Your API will be available at the URL displayed on the dashboard after successful deployment.
Ensure the following environment variables are set in your Cloudflare Workers environment:
DATABASE_URL: Your Prisma Accelerate URLJWT_SECRET: Secret key for JWT token generation and validation