Skip to content

CallMeSahu/app-task-management

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

13 Commits
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Task Management API

πŸš€ Project Overview

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.

⚑ Why this stack?

  • 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.

πŸ› οΈ Local Setup

πŸ“‹ Prerequisites

  • Node.js (v16 or newer)
  • PostgreSQL database
  • Cloudflare account
  • Prisma Accelerate account

πŸ“ Setup Instructions

  1. Clone the repository and navigate to the backend directory:

    git clone https://github.com/CallMeSahu/app-task-management.git
    cd app-task-management/backend
  2. Install dependencies:

    npm install
  3. 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
  4. Create a .env file:

    touch .env
  5. Add the following content to .env:

    DATABASE_URL="your_postgres_url"
    
  6. Create a wrangler.toml file:

    touch wrangler.toml
  7. 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"
  8. Migrate your database:

    npx prisma migrate dev --name init_schema
  9. Generate Prisma client:

    npx prisma generate --no-engine
  10. Run the application locally:

    npx wrangler dev

πŸ”Œ API Endpoints

🌐 Base URL

The API is deployed on Cloudflare Workers and accessible using the following link:

Production API URL

https://app-task-management.siddharthasahu-work.workers.dev

πŸ”’ Authentication

All endpoints except for registration and login require JWT authentication. Include the JWT token in the Authorization Header:

Authorization: Bearer <your_jwt_token>

πŸ‘€ User Endpoints

πŸ“ Register a new user

  • 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"
    }

πŸ”‘ User Login

  • URL: /api/v1/user/signin
  • Method: POST
  • Auth Required: No
  • Request Body:
    {
      "email": "test@test.com",
      "password": "Test@123"
    }
  • Response:
    {
      "token": "jwt_token_here"
    }

βœ… Task Endpoints

βž• Create Task

  • 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"
      }
    }

πŸ“‹ Get All Tasks

  • 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"
          }
      ]
    }

πŸ”„ Update Task

  • 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"
      }
    }

πŸ—‘οΈ Delete Task

  • URL: /api/v1/task/:id
  • Method: DELETE
  • Auth Required: Yes
  • Response:
    {
      "message": "Task deleted successfully"
    }

πŸ“¦ Postman Collection

You can access and import the Postman collection for testing this API using the following link:

Task Management API Postman Collection

πŸš€ Deployment

The API is deployed on Cloudflare Workers, which provides edge computing capabilities for low-latency globally distributed access.

πŸ“ Deployment Steps

  1. Authenticate with Cloudflare:

    npx wrangler login
  2. Deploy the application:

    npx wrangler deploy
  3. Your API will be available at the URL displayed on the dashboard after successful deployment.

πŸ” Environment Variables for Production

Ensure the following environment variables are set in your Cloudflare Workers environment:

  • DATABASE_URL: Your Prisma Accelerate URL
  • JWT_SECRET: Secret key for JWT token generation and validation

πŸ“– Additional Resources

About

This project is a task management API built using modern technologies to provide high performance and scalability.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published