Very simple RESTful starter in NodeJS + MongoDB with JWT Authentication
- Clone this repo using
https://github.com/skorotkiewicz/node-rest-api-jwt.git
- Move to the appropriate directory:
cd node-rest-api-jwt
. - Run
npm install
to install dependencies. - Set
.env
file with your mongoURI. - Run
5.1npm run dev
(nodemon)
5.2npm start
(without nodemon)
-
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