This API provides basic CRUD functionality for managing todos. Built using Koa.js and Better-SQLite3, it demonstrates the implementation of a RESTful API with various endpoints for creating, reading, updating, and deleting todos.
- Koa.js: A modern, lightweight, and expressive web framework for Node.js.
- Better-SQLite3: A fast and simple SQLite database library for Node.js.
- Jest: A delightful JavaScript testing framework for unit testing(WIP).
- Supertest: A SuperAgent driven library for testing HTTP servers(WIP).
Throughout this project, I've learned and implemented:
- Koa.js Fundamentals: Explored the core concepts of Koa.js, including middleware, context, and routing, to create a robust API.
- Database Interaction: Implemented CRUD operations using Better-SQLite3, ensuring secure and efficient data management.
- RESTful API Design: Designed RESTful endpoints following best practices for creating, reading, updating, and deleting resources.
- Testing with Jest: Utilized Jest and Supertest for writing extensive unit tests to validate API functionality and handle edge cases.
- Error Handling: Implemented error handling mechanisms to ensure graceful handling of various error scenarios(WIP).
- HTTP Methods and Status Codes: Understood the significance of different HTTP methods (GET, POST, PUT, DELETE) and corresponding status codes in API development.
-
Initialization:
- The API initializes a SQLite database with a 'todos' table for storing todo items.
- The server starts on port 3000.
-
Endpoints:
- GET
/todos
: Retrieves a list of todos. - POST
/todos
: Creates a new todo item. - PUT
/todos/:id
: Updates an existing todo item by ID. - DELETE
/todos/:id
: Deletes a todo item by ID.
- GET
-
Testing:
- Unit tests for the API are written using Jest and Supertest to ensure each endpoint's functionality and handle various scenarios.
-
Clone the Repository:
git clone https://github.com/musagenius3455/koa-RESTful-API.git cd koa-RESTful-API
-
Install Dependencies:
npm install
-
Run the API:
npm start
-
Run Tests:
npm test
Contributions are welcome! Feel free to open issues or submit pull requests to help improve this project.
This project is licensed under the MIT License.