A basic template for a server token authorization
Parameter | Type | Description |
---|---|---|
string | User e-mail | |
pass | string | User password |
Method | Auth | Path | Description | Body JSON |
---|---|---|---|---|
GET | / | "Hello World" | ||
POST | /register | Create a new user | User | |
POST | /login | Generates a new JWT | User | |
GET | JWT | /validate | Validate JWT | |
GET | JWT | /dashboard/ | Protected route | |
GET | JWT | /dashboard/users | Get all users |
Install dependencies:
npm i
Add .env file:
MONGO_URI=<mongo uri string>
PORT=<server port listening>
JW_SECRET=<json web token secret>
JW_EXPIRATION=<in seconds>
Run node project:
node index.js
- node.js
- express
- mongoose
- jwt
Izan Pérez Cosano (https://github.com/eperezcosano)