A simple authenticated TODO app backend built with Node.js, Express, PostgreSQL, Prisma, and JWT. Includes complete CRUD functionality and user authentication.
- User Signup and Signin (JWT-based authentication)
- Add, Get, Update, and Delete TODOs
- Secure routes with authentication middleware
- Request collection included (Bruno format)
.
├── bruno/ # API request collection (Bruno)
│ └── *.bru # Bruno HTTP request definitions
├── prisma/
│ └── schema.prisma # Prisma schema
├── src/
│ ├── controllers/ # Route logic for user and todos
│ ├── middlewares/ # JWT auth middleware
│ ├── prisma/ # Prisma client setup
│ ├── routes/ # Express routes
│ └── server.js # Entry point
├── .env.example # Sample environment variables
├── .gitignore
└── package.json
- Node.js & Express — Backend server
- Prisma ORM — DB access with PostgreSQL
- PostgreSQL — Relational database
- JWT — Authentication
- bcrypt — Password hashing
- Bruno — API testing
git clone https://github.com/KiranRajeev-KV/backend-todo-api-js.git
cd backend-todo-api-js
npm install
Create a .env
file based on .env.example
:
DATABASE_URL=postgresql://your_user:your_pass@localhost:5432/your_db
JWT_SECRET=your_super_secret
npx prisma migrate dev --name init
npm run dev
The server will start on http://localhost:8080
(or as configured).
All /api/todos
routes are protected with a Bearer
token (JWT).
After signing in, include the token in headers:
Authorization: Bearer <your_token_here>
Method | Endpoint | Description |
---|---|---|
POST | /api/user/signup |
Register new user |
POST | /api/user/signin |
Login and get token |
Method | Endpoint | Description |
---|---|---|
POST | /api/todos/ |
Add new TODO |
GET | /api/todos/ |
Get all TODOs |
GET | /api/todos/:id |
Get TODO by ID |
PUT | /api/todos/:id |
Toggle completion status |
DELETE | /api/todos/:id |
Delete TODO by ID |
DELETE | /api/todos/ |
Delete all TODOs by user |
Use the Bruno app to test APIs (./bruno
directory).
Install Bruno from bruno.io, then open the folder to use predefined requests.