npm i nodeevel
let {
prepareError,
prepareResponse,
sendMail,
createFilenameHash,
is400,
is401,
is403,
is404,
server,
} = require('nodeevel');
Method to create standard server node, with express, consign, knex
server(db:object, port:number, ...entities)
Method to send mail with nodemailer
sendMail(data: object, credentials: object, configs: object)
Method to create the hash with filename
createFilenameHash(name:string)
is400(message: string)
is401(message: string)
is403(message: string)
is404(message: string)
Method to prepare the generated an object with StatusHttp and message with the error founded
prepareError(error:object|string, customKeys:string = null)
Method to response the API with Status and message with base the raw error
prepareResponse(response: from express, error:object|string, prettyErr: string = null)
Standard class to Make backend validations with common rules (e.g required)
const { Validatorus: Validator } = require('nodeevel')
new Validator({
"username": "the name of the user",
"password": "the password of the user",
})
Standard Model class work wih the validator and serve the standard method of CRUD
const { Modelus: Model } = require('nodeevel')
class User extends Model {
constructor(app){
const fillables = ["id", "name", "username", "email"]
const hiddens = ["password"]
const rules = {
"name" : "required|max:80",
"username" : "required|min:5|max:80|vusername",
"email" : "required|mail|max:120",
"password" : "required:create|min:8|max:80",
"confirmation" : "required:create|min:8|max:80|compare:password",
}
super(app, "users", rules, fillables, hiddens)
}
}