An open API service indexing awesome lists of open source software.

https://github.com/skorotkiewicz/node-rest-api-jwt

Simple Node.js RESTful API with JWT Authentication and MongoDB
https://github.com/skorotkiewicz/node-rest-api-jwt

Last synced: 2 months ago
JSON representation

Simple Node.js RESTful API with JWT Authentication and MongoDB

Awesome Lists containing this project

README

        


RESTful API with MongoDB and JWT Authentication


Very simple RESTful starter in NodeJS + MongoDB with JWT Authentication

## Getting started

1. Clone this repo using `https://github.com/skorotkiewicz/node-rest-api-jwt.git`
2. Move to the appropriate directory: `cd node-rest-api-jwt`.
3. Run `npm install` to install dependencies.
4. Set `.env` file with your mongoURI.
5. Run
5.1 `npm run dev` (nodemon)
5.2 `npm start` (without nodemon)

## Basic usage

* Get all the posts
`GET http://localhost:3000/posts`

* Get a specific Post
`GET http://localhost:3000/post/5ae63c5027bbe422cce696a3`

* Register User
`POST http://localhost:3000/users/register`

Headers:
- Content-Type: application/json

Body:
- name
- email
- password

___
* Authenticate User
`POST http://localhost:3000/users/authenticate`

Headers:
- Content-Type: application/json

Body:
- email
- password
___
* Create new Post
`POST http://localhost:3000/action/create`

Headers:
- x-access-token
- Content-Type: application/json

Body:
- title
- description
___
* Update a Post
`PATCH http://localhost:3000/action/5ae63c5027bbe422cce696a3`

Headers:
- x-access-token
- Content-Type: application/json

Body:
- title
- description
___
* Delete Post
`DELETE http://localhost:3000/action/5ae63c5027bbe422cce696a3`

Headers:
- x-access-token
- Content-Type: application/json