Skip to content

bearmentor-community/express-auth-api

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

95 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

Example Auth Express

Example Auth API with Express.

Links

Stack

  • REST API
  • Express
    • Body Parser
    • Cookie Parser
    • bcrypt
    • JWT
  • Debug
  • Morgan
  • Postman
  • MongoDB, Mongoose, and mLab
    • Later: MySQL, Sequelize, and MySQL instance
  • Heroku
    • Later: Amazon EBS
    • Later: Google App Engine
  • Cloudflare
  • Uniregistry

Features

  • Seed new users
  • Register new user
    • Name
    • Email
    • Password encrypted using bcrypt
  • Login to existing user
    • Email
    • Password
    • Authorization token with JWT
  • Get all users
    • Don't show the password
  • Get user by id
    • Don't show the password
  • Search users by name
  • Remove all users

REST API Specification

Index

Endpoint HTTP Description
/ GET Get index title

Auth

Endpoint HTTP Description
/auth/register POST Register new user
/auth/login POST Login to existing user
/auth/logout POST Logout the logged in user
/auth/validate POST Check if user token is valid

Users

Endpoint HTTP Description
/users/seed POST Seed initial users
/users GET Get all users
/users/:id GET Get user by id
/users/:id PUT Update user by id
/users/:id DELETE Delete user by id
/users DELETE Delete all users
/users/profile GET Get authenticated user profile
/users/search?name= GET Search user by name

Usage

Setup Environment Variables

Development

Run the setup.sh script first, to copy .env.schema into .env.

./setup.sh

Then you fill the variables in .env file. Remember to install and make sure MongoDB is running on your machine.

MONGODB_URI=mongodb://localhost:27017
JWT_SECRET=this_is_your_secret

Production

MONGODB_URI=mongodb://urltomongodb.com:27017
JWT_SECRET=this_is_your_other_secret

Install Dependencies

yarn

Run Development Server

yarn dev

Run Production Server

yarn start

Run Test Suite

yarn test

Seed Initial Data

Run Postman collection.

Debug Production on Heroku

heroku logs --tail -a api-haidar-dev

License

MIT

About

๐Ÿš„ Project Auth API with Node.js, Express, MongoDB, and Mongoose

Topics

Resources

License

Stars

Watchers

Forks