This project is a RESTful API built with Express.js and Sequelize ORM using MySQL as the database. It provides CRUD operations for a Course
model.
- CRUD operations for a
Course
model. - Error handling for existing and non-existing resources.
- Input validation using express-validator.
- API documentation with Swagger.
- Clone the repository:
git clone https://github.com/yourusername/your-repo-name.git
- Install dependencies:
cd your-repo-name npm install
- Create a
.env
file in the root directory of the project and add your MySQL configurations:DB_HOST=localhost DB_USER=root DB_PASSWORD=yourpassword DB_NAME=yourdbname DIALECT=yoursqldialect
- Run the server:
npm run dev
GET /courses
: Fetch all courses.GET /courses/:id
: Fetch a single course by ID.POST /courses
: Create a new course.PUT /courses/:id
: Update a course by ID.DELETE /courses/:id
: Delete a course by ID.
The API has a global error handling middleware for handling existing and non-existing resources.
The API uses express-validator to validate user input.
The API documentation is done using Swagger. You can access it at /api-docs
.
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.
MIT