1.0.3 • Published 4 years ago
maxipublica-auth v1.0.3
Valid Authorization and Token
Installation
Latest release:
$ npm i maxipublica-auth
Overview
Initialize Module
const valid = require("maxipublica-auth").Validator;
const password = "Any password";
const dbConecction = require("../database");
const valid = new mxp_valid(password, dbConecction);
Creating Authorizations
valid
.createAuthorization({
sellerId: "1", //sellerId is required
userId: "5", //userId is required
type: "admin", //type is required
rol: "admin", //rol is required
request: {
post: 30, //default is 1000
put: 60, //default is 1000
get: 100, //default is 1000
path: 500 //default is 1000
}
})
.then(authorization => {
/*The promise return
* the new authorization
*/
return authorization;
})
.catch(err => {
/*The promise error return
* status : Number
* name : String
* message : String
* customMessage : String
*/
return err;
});
Valid authorizations
valid
.authorization("Any authorization", "method") //if method is undefined or null for default is get
.then(isValid => {
/*The promise return
* method : String
* request : Object
* sellerId : Number
* userId : Number
* type : String
* rol : Strings
*/
return true;
})
.catch(err => {
/*The promise error return
* status : Number
* name : String
* message : String
* customMessage : String
*/
return err;
});
Valid token
valid
.token("Any token", "method") //if method is undefined or null for default is get
.then(isValid => {
/*The promise return
* method : String
* request : Object
* sellerId : Number
* userId : Number
* type : String
* rol : Strings
*/
return true;
})
.catch(err => {
/*The promise error return
* status : Number
* name : String
* message : String
* customMessage : String
*/
return err;
});
Autores ✒️
Menciona a todos aquellos que ayudaron a levantar el proyecto desde sus inicios
Expresiones de Gratitud 🎁
- Invita una cerveza 🍺 a alguien del equipo.
- Da las gracias públicamente 🤓.
- etc.
⌨️ con ❤️ por cdelacruz 😊