Code Monkey home page Code Monkey logo

courses-api's Introduction

Express.js RESTful API with Sequelize and MySQL

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.

Screenshot 2023-11-02 at 1 11 31 AM (2)

Features

  • CRUD operations for a Course model.
  • Error handling for existing and non-existing resources.
  • Input validation using express-validator.
  • API documentation with Swagger.

Getting Started

Installation

  1. Clone the repository:
    git clone https://github.com/yourusername/your-repo-name.git
    
  2. Install dependencies:
    cd your-repo-name
    npm install
    
  3. 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
    
  4. Run the server:
    npm run dev
    

API Endpoints

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

Error Handling

The API has a global error handling middleware for handling existing and non-existing resources.

Input Validation

The API uses express-validator to validate user input.

API Documentation

The API documentation is done using Swagger. You can access it at /api-docs.

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

License

MIT

courses-api's People

Contributors

heba-webdev avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.