GithubHelp home page GithubHelp logo

prashant-bhatt / node-api-auth Goto Github PK

View Code? Open in Web Editor NEW
3.0 1.0 0.0 3.07 MB

This is a complete initial setup of APIs with authentication in node. Technology includes node, mongoose, express, JWT, passportjs. Download and use this app as initial setup of node apis and enhance it according to your requirements..

JavaScript 100.00%
nodejs nodejs-development express mongodb mongoose api api-rest jwt-authentication jwt-token nodeapiwithjwttoken jwtauth jwt nodeapi expressapi

node-api-auth's Introduction

node api authorization

This is a complete initial setup of APIs with authentication in node. Technology includes node, mongoose, express, JWT, passportjs. Download and use this app as initial setup of node apis and enhance it according to your requirements..

Prerequisite

  1. node js
  2. mongo db

Installation and Usage Steps -

i) Clone or download project in your system

ii) Run "npm install" to install all modules defined in package json.

ii) Run app.js File using - "node app.js" OR just use nodemon if you have installed it on your system

Example APIs

1) Register API

URL: http://localhost:2000/users/register

Request Type: POST

Headers- Content-Type:application/json

Body Params: { "name":"prashant bhatt", "email":"[email protected]", "password":"test", "username":"prashant" }

Response:-

{ "success": true, "msg": "User Registered" }

2) Authenticate API

URL: http://localhost:2000/users/authenticate

Request Type: POST

Headers- Content-Type:application/json

Body Params: { "password":"test", "username":"prashant" }

Response:-

{ "success": true, "token": "JWT token string", "user": { "id": "59653c1fdcb0d5398830010a", "name": "prashant", "username": "prashant", "email": "[email protected]" } }

Note - This token will be used in all future calls

  1. Get User Profile (A call to check if token verification working)

URL: http://localhost:2000/users/profile

Request Type: GET

Headers- Content-Type:application/json

Authorization:JWT Token HERE

Response:- { "msg": "hiii" }

Enhance the API by creating your own Controllers and models.

node-api-auth's People

Contributors

prashant-bhatt avatar prashant-mobikasa avatar

Stargazers

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