RESTful API made with Node.js where a registered user can list, create, update or delete courses that are stored in a database. It will be needed a token, which will be received when you log in.
- MongoDB
- Redis
- Node.js
- NPM / Yarn
- Clone the repository:
https://github.com/kazordoon/nodejs-restful-api-express.git
- Get in the project directory:
cd nodejs-restful-api-express
- Install the dependencies:
- NPM:
npm i
| Remove the fileyarn.lock
before installing with NPM - Yarn:
yarn
- NPM:
Copy the .env.example
file to the .env
, then you will need to set the variable values into the .env
file according to your environment.
- NPM:
npm run dev
- Yarn:
yarn dev
Action | Path | Body | Method | Returns |
---|---|---|---|---|
Create a new user | /auth/register | A JSON with these fields | POST | A JSON with a token |
Login into an account | /auth/login | A JSON with these fields | POST | A JSON with a token |
Action | Path | Parameters | Body | Method | Returns |
---|---|---|---|---|---|
List all courses | /courses | -- | -- | GET | All courses |
List one course | /courses/{id} | id | -- | GET | The course that has the same id as the one found in the id parameter |
Create a new course | /courses | - | A JSON with these fields | POST | The created course |
Update a existing course | /courses/{id} | id | A JSON with at least one of these fields | PATCH | The updated course |
Delete a course | /courses/{id} | id | -- | DELETE | -- |
You need to put the token on the authorization header.
- username
- Type: string
- Minimium characters: 3
- Maximium characters: 20
- password
- Type: string
- Minimium characters: 8
- Maximium characters: 50
- name:
- Type: string
- Minimium characters: 5
- Maximium characters: 50
- description
- Type: string
- Minimium characters: 15
- Maximium characters: 100
- workload
- Type: number
- Minimium: 1
- total_classes
- Type: number
- Minimum: 1
- year
- Type: number
- Minimum: 1970
- Maximum: <current_year>
See the EXAMPLES.md.
- Node.js - JavaScript runtime environment that executes JavaScript code server-side
- MongoDB - NoSQL Database
- mongoose - MongoDB object modeling tool
- express - Minimalist web framework for Node.js
- consign - Autoload for the scripts
- cors Node.js CORS middleware
- express-validator - Data input validator
- bcryptjs - A library to help you hash passwords
- jsonwebtoken - An implementation of JSON Web Tokens
- ioredis - A robust, performance-focused and full-featured Redis client for Node.js
For the versions available, see the tags on this repository.
- Felipe Barros - Initial work - kazordoon
This project is licensed under the MIT License - see the LICENSE file for details