/api-restful

Prendre en main les notions de création de api restful avec du nodejs, express, mysql

Primary LanguageJavaScript

nodejs-crud-api

Node.js, Express and MySql: Create a Restfull API

What will you learn ?

What will you learn by downloading my code?

  • Use of express to make API creation simple
  • Field validation using express-validator
  • Creation of a functional REST API with Node.js, Express and MySql.

Are you ready ? Let's go!

Step 1: Installing dependencies

Clone the repository then run npm install

Step 2: Link your api to MySql

Go to the index.js file and replace the database name nodejs_etudiant with yours.

Step 3: Launch your project

To launch your project, just type the following command : node app.js. Your API will therefore run on port 3000

Step 4: Test the API endpoints

This is an API that manages students. A student is characterized by:

  • id: the student's id
  • first name: the first name of the student
  • last name: the student's last name
  • faculty: the student's faculty

Examples of API tests with postman (in pictures)