Code Monkey home page Code Monkey logo

express-auth-api's Introduction

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

express-auth-api's People

Contributors

mhaidarhanif avatar

Stargazers

 avatar Raafi Haswoto avatar

Watchers

 avatar James Cloos 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.