Socket
Socket
Sign inDemoInstall

nodeevel

Package Overview
Dependencies
7
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    nodeevel

Module Back-end End with common Util to Node projects


Version published
Weekly downloads
1
Maintainers
1
Created
Weekly downloads
 

Readme

Source

A Node package with commun method to works a backend node

install package
npm i nodeevel

Require modules

let { 
    prepareError, 
    prepareResponse, 
    sendMail,
    createFilenameHash, 
    is400, 
    is401, 
    is403, 
    is404,
    server,
} = require('nodeevel');

Factories

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)

Common Services

Method to create the hash with filename

createFilenameHash(name:string)

http 4xx return object

is400(message: string)
is401(message: string)
is403(message: string)
is404(message: string)

Error Handler

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)

Class

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)
    }
}

Keywords

FAQs

Last updated on 02 Sep 2021

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc