1.1.8 • Published 2 years ago

ywemay-api-user v1.1.8

Weekly downloads
-
License
ISC
Repository
github
Last release
2 years ago

API User

Provides authentication/authorization functions for a Mongo DB based user.

Setup

#install the module:
npm i ywemay-api-user

NOTE: This module requires a Mongoose connection to operate.

The .env file should contain the following keys with appropriate values:

# a string used to encrypt the token:
JWT_KEY="replace this string with any random string for token encryption"
# how many tries to login are allowed until user is delayed (by IP)
LOGIN_MAX_TRIES=10
# how long time to wait (minutes) until log in is allowed again
LOGIN_DELAY=20

Usage example:

This is how user routes may be added to the application:

const express = require("express");
const db = require("./db");
const users = require("ywemay-api-user");

// initialize express application
const app = express();
app.use(express.json());

db.connect();

users.config(app);

module.exports = app;

Endpoints

POST /auth/login
GET /auth/logout

POST /avatar/upload
GET /img/avatar

GET /user/preferences
PUT /user/preferences
PUT /user/change-password

GET /users
GET /users/id/:uid
GET /ref
POST /users
PUT /users/id/:uid
PUT /users
DELETE /users/id:uid
DELETE /users
1.1.8

2 years ago

1.1.7

2 years ago

1.1.5

2 years ago

1.1.4

2 years ago

1.1.3

2 years ago

1.1.2

2 years ago

1.1.1

2 years ago

1.1.0

2 years ago

1.0.4

2 years ago

1.0.3

2 years ago

1.0.2

2 years ago

1.0.1

2 years ago