GithubHelp home page GithubHelp logo

pg9-dev / auth Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 1.16 MB

Auth is a backend authentication server exposing a RESTFUL API to requesting clients. It uses jwt tokens to authenticate users and keep them logged in.

JavaScript 100.00%

auth's Introduction

Description


Auth is a backend authentication server exposing a RESTFUL API to requesting clients. It uses jwt tokens to authenticate users and keep them logged in.

Database Schema

UserModel

User Model

A simplistic model for user to illustrate the authentication example.

Instructions to run


This project is packaged via npm; the respective package.json file contains all required scripts.

In order to the run the project, the dependencies need to be installed first.


To install all dependencies:

    `yarn install` or `npm install`

To start the server:

    `yarn start` or `npm start`

The project expects a mongoDB database server with the appropriate mongoose configuration; failure to find a database-server would cause the server to throw an error. The project expects the connection to saved in a .env file against the variable DB_CONNECT.

If database configurations are met then the server will launch at localhost:8000/ and listen for incoming requests. The project is ran via nodemon, any changes in the files would cause the server to restart for a faster dev. experience.

REST API: GET and POST requests

POST REQUESTS


Register User

POST api/user/register

Body
{
  "name":"sampleName",
  "password":"sampelPassword",
  "email":"[email protected]"
}

Expected Response

{
    "user": "userID"
}

Login User

POST api/user/login

Body
{
  "email":"[email protected]",
  "password":"sampelPassword"
}

Expected Response

{
    "auth-token": "token"
}

Access Protected Route

GET api/posts

Header
{
  "auth-token":"token"
}

Expected Response

{
    "name": "userName"
}

Get All Users

GET api/user

Expected Response

[
    {
        "name": "sampleName",
        "email": "[email protected]"
    }
]

Acknowledgement

This project is based on tutorials by youtuber DevEd. Here is a link to Ben's channel: https://www.youtube.com/watch?v=2jqok-WgelI99baddawg; like, share and follow his channel if you appreciate the content.

auth's People

Contributors

pg9-dev avatar

Watchers

 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.