npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

mcarz-back-utils

v3.3.1

Published

Module Back-end End with common Util to Node projects

Downloads

11

Readme

A Node package with commun method to works a backend node

install package

npm i mcarz-back-utils

Require modules

let { 
    prepareError, 
    prepareResponse, 
    sendMail,
    createFilenameHash, 
    is400, 
    is401, 
    is403, 
    is404,
    server,
} = require('mcarz-back-utils');

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('mcarz-back-utils')

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('mcarz-back-utils')
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)
    }
}