1.0.2 • Published 5 years ago
@mauth/jwt-auth v1.0.2
jwt-auth
Node.js package for JWT access token authentication.
Installation
Via git:
$ git clone https://github.com/Mkrtichh/jwt-auth.git
Via npm:
$ npm install @mauth/jwt-auth
Internal database init
// Init database with custom options.
const auth = require('@mauth/jwt-auth');
auth.initDb({
database: 'db_name',
username: 'user_name',
password: "root",
dialect: 'postgres', // MySql
host: "localhost",
port: 5432,
});
Basic signUp example
// signUp method.
const auth = require('@mauth/jwt-auth');
auth.signUpUser({
username: 'username',
email: 'example@gmail.com',
password: "password"
},
(err, data) => {}
);
Basic login example
// signUp method.
const auth = require('@mauth/jwt-auth');
auth.login({
username: 'username' || email: 'example@gmail.com',
password: "password"
},
(err, data) => {}
);
Basic authentication example with server
// signUp method.
const auth = require('@mauth/jwt-auth');
app.use(auth.authenticate, someHandler);
Dependencies
- jsonwebtoken - An implementation of JSON Web Tokens.
- bcrypt.js - Optimized bcrypt in plain JavaScript with zero dependencies.
- sequelize.js - An easy-to-use multi SQL dialect ORM for Node.js.
Copyright (c) Mkrtich Muradyan