Skip to content

AliiMahmoud/Node-API-jwt-authentication

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

36 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

API CRUD Node APP (Express + MongoDB) with JWT auth.

This app Performs API CRUD operations on mongodb movies database.

   - Authorization/Generate access token
   - CRUD on movies/theater
   - CRUD on movie's comment  

Setting things

To get the Node server running:

  • Download Node.js here
  • npm install to install all required dependencies
  • Install MongoDB instructions

Documentation

Project Overview

Application Structure src/

  • app.js - The entry point to the application. This file defines our express server, requires the routers and some middlewares.
  • db.js - This file connects the app to MongoDB using MongoDB node.js driver
  • routers/ - Folder contains the route definitions for the app.
  • middlewares/ - Folder contains our middlewares to handle some requests (jwt, error handler).
  • controllers/ - This folder contains main controllers.
  • models/ - This folder contains the data models.
  • models/modelname/schema - This file contain JOI's data validation schema for every data model.

Dependencies

[
    "dotenv", "express", "express-jwt", "joi", "jsonwebtoken", "md5", "mongodb", "morgan", "swagger-ui-express"
]
  • express - The server for handling and routing requests
  • mongodb - The official MongoDB driver for Node.js.
  • jsonwebtoken - For generating JWTs used by authentication
  • express-jwt - Middleware for validating JWTs for authentication
  • Joi - A schema description language and data validator for JS.
  • dotenv - A module to load environment variables from a .env file into process.env
  • morgan - Request logger middleware
  • swagger-ui-express - Swagger package for API documentation

Useful Resources