Skip to content
This repository has been archived by the owner on Aug 23, 2021. It is now read-only.
/ ExpressAPI Public archive

An Express/MongoDB based REST API with Passport token authentication

Notifications You must be signed in to change notification settings

fairbanksio/ExpressAPI

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

76 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ExpressAPI

An Express/MongoDB based REST API with Passport token authentication.

Prerequisites

  • MongoDB instance

Deployment

  • Install Dependencies

yarn install

  • Start Server

MONGO_URI='mongodb://user:pass@hostname:27017/db' yarn start

  • Validate

Navigate to http://hostname:3000/ and confirm you receive the below response:

{"message":"Connected!"}

Usage

You must first register, then login to receive the token which you can then use for the other endpoints. You only need to call login with user/pass if already registered.

Get Authentication Token

  • Register a new user

POST {name: nameVALUE, username: userVALUE, password: passVALUE} to /auth/register

  • Login to get authentication token

POST {username: userVALUE, password: passVALUE} to /auth/login

Save the token from the response object {token} as it will be needed for all other api calls

User object API

This API requires you to set header: authorization for each request to the JWT token received from 'login'

  • Get a list of users

GET /users

  • Get user by userID

GET /users/:userID

  • Update a user by userID

POST /users/:userID

  • Delete a user by userID

DELETE /users/:userID

About

An Express/MongoDB based REST API with Passport token authentication

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published