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

https://github.com/eperezcosano/auth-server-template

A basic template for a server token authorization
https://github.com/eperezcosano/auth-server-template

express jwt jwt-auth jwt-server mongodb mongoose nodejs

Last synced: 2 months ago
JSON representation

A basic template for a server token authorization

Awesome Lists containing this project

README

          

# API Server JWT Auth
A basic template for a server token authorization

## Models

### User

| Parameter | Type | Description |
|:----------|:-------|:--------------|
| email | string | User e-mail |
| pass | string | User password |

## Routes

| Method | Auth | Path | Description | Body JSON |
|:------:|------|------------------|---------------------|-------------------------------------------------------------------|
| GET | | / | "Hello World" | |
| POST | | /register | Create a new user | [User](https://github.com/eperezcosano/auth-server-template#user) |
| POST | | /login | Generates a new JWT | [User](https://github.com/eperezcosano/auth-server-template#user) |
| GET | JWT | /validate | Validate JWT | |
| GET | JWT | /dashboard/ | Protected route | |
| GET | JWT | /dashboard/users | Get all users | |

## Installation

Install dependencies:

```
npm i
```

Add .env file:

```
MONGO_URI=
PORT=
JW_SECRET=
JW_EXPIRATION=
```

Run node project:

```
node index.js
```

## Technologies

- node.js
- express
- mongoose
- jwt

## Author Info

Izan Pérez Cosano (https://github.com/eperezcosano)