A simple and efficient backend API for managing a Todo application built with Node.js, Express.js, and PostgreSQL.
- Manage Todo items with CRUD operations.
- RESTful API built with Node.js and Express.js.
- PostgreSQL as the database.
- CORS support for cross-origin requests.
- ( https://nodejs.org/docs/latest/api/ ) Node.js
- ( https://www.postgresql.org/download/ ) PostgreSQL
- ( https://docs.npmjs.com/downloading-and-installing-node-js-and-npm ) npm
-
Clone the repository:
git clone [email protected]:Vinayak-kumar-sharma/backend-todo-curd.git cd todo-backend
-
Install dependencies :
npm install
-
Set up the database:
Create a PostgreSQL database.
Update the DATABASE_URL in your environment variables.
-
Run database migrations:
-
Start the server:
After starting the server, the API will be available at ( http://localhost:PortNumber ). You can use tools like Postman to interact with the endpoints.
-
Get all Todos
-
GET /
-
Resposne:
[ { "id": 1, "title":"sample todo desc." } ]
-
-
Get a single Todo
-
GET /todo/:id
-
Response:
{ "id":1, "title":"sample todo desc." }
-
-
Create a Todo
POST /todo
- Request:
{ "title":"New todo" }
-
Update a Todo
PUT /todos/:id
- Request
{ "title":"Updated todo" }
-
Delete a Todo
DELETE /todo/:id
- Response:
{ "message": "Todo was deleted!" }
Contributions are welcome! Please open an issue or submit a pull request for any improvements or bug fixes.
-
Fork the repository.
-
Create a new branch (
git checkout -b branch-name
) . -
Commit your changes (
git commit -m 'Add some feature'
). -
Push to the branch (
git push origin branch-name
). -
Open a pull request.
Feel free to give your valuable feedback:
- GitHub: Vinayak-kumar-sharma
Happy Codding 🚀