@milcgroup/common-modules
Set of modules, utils, models, to be shared between milcgroup apps
Last updated 8 months ago by ddelgadocds .
Original npm · Tarball · package.json
$ cnpm install @milcgroup/common-modules 
SYNC missed versions from official npm registry.

Milcgroup Common Modules Package

This package collects common code for Milcgroup applications such as Sequelize Models, Utils and Helpers.

Installation

npm install @milcgroup/common-modules --save or yarn add @milcgroup/common-modules

Usage

// OR import for ES5
const common = require('@milcgroup/common-modules')

// 1. Models
const User = common.models.User
User.findAll({
  ...
})

// 2. Utils
const randomToken = common.utils.tokenizer.getRandom();

// 3. Helpers

const modelHelpers = common.helpers.modelHelpers;
modelHelpers.getCannedFields('entity_id', null, DataTypes);

Modules

Models

Sequelize models with common entities. See below list with the models you can import and add to the Sequelize setup.

  • User
  • Company
  • Facility
  • UserFacility
  • Permission

Utils

Common utilities and methods. See below list with the utilities you can import.

  • Tokenizer

    • getRandom():Promise(string) : Returns a random HEX string
    • getJWT(obj, secret, expirationTime):Promise(string) : Returns a token encrypting the obj data using the secret. The token is valid by the period specified in expirationTime
    • verifyJWT(token, secret):Promise(obj) : Validates a given token using the secret. Returns the decoded obj
    • computePasswordHash(password):Promise(string) : Returns a hashed password
  • Cache This utility exports some common functions to manage the Redis cache.

    • set(key, val):Promise()
    • get(key):Promise(val)
    • hget(key, prop):Promise(val)
    • hgetset(key, prop, value):Promise(string)
    • hset(key, prop, value):Promise()
    • hdel(key, prop):Promise()
    • quit()
  • Auth Some middlware functions for auth

    • verifyAccessToken(req, res):Promise()
    • checkTokenExpiration(req)

Helpers

Common methods and helpers. See below list with the helpers you can import.

  • modelHelpers

    • getConfig():obj : Returns Sequelize config with options like paranoid, underscored
    • getCannedFields(idField, nameField, DataTypes) : Returns Sequelize objects for the primary key and and the underscored name.
    • getFormattedResult(data) : Returns a formatted model result without timestamps
  • requestHelpers

  • getOrderParams(req):obj

  • getOrderParamsFromString(orderByString)

  • getFacilityWhere(req, facilityIds, fld):obj

  • filterInactive(req, params)

  • filterCollections(req, row)

Current Tags

  • 1.37.0                                ...           latest (8 months ago)

125 Versions

  • 1.37.0                                ...           8 months ago
  • 1.36.0                                ...           8 months ago
  • 1.35.0                                ...           8 months ago
  • 1.34.0                                ...           8 months ago
  • 1.33.0                                ...           8 months ago
  • 1.32.1                                ...           8 months ago
  • 1.32.0                                ...           8 months ago
  • 1.31.0                                ...           9 months ago
  • 1.30.1                                ...           a year ago
  • 1.30.0                                ...           a year ago
  • 1.29.0                                ...           a year ago
  • 1.28.0                                ...           a year ago
  • 1.27.0                                ...           a year ago
  • 1.26.0                                ...           a year ago
  • 1.25.2                                ...           a year ago
  • 1.25.1                                ...           a year ago
  • 1.25.0                                ...           a year ago
  • 1.24.4                                ...           a year ago
  • 1.24.3                                ...           a year ago
  • 1.24.2                                ...           a year ago
  • 1.24.1                                ...           2 years ago
  • 1.24.0                                ...           2 years ago
  • 1.23.0                                ...           2 years ago
  • 1.22.0                                ...           2 years ago
  • 1.21.2                                ...           2 years ago
  • 1.21.1                                ...           2 years ago
  • 1.21.0                                ...           2 years ago
  • 1.20.0                                ...           2 years ago
  • 1.19.1                                ...           2 years ago
  • 1.19.0                                ...           2 years ago
  • 1.17.0                                ...           2 years ago
  • 1.16.6                                ...           2 years ago
  • 1.16.5                                ...           2 years ago
  • 1.16.4                                ...           2 years ago
  • 1.16.3                                ...           2 years ago
  • 1.16.2                                ...           2 years ago
  • 1.16.1                                ...           2 years ago
  • 1.16.0                                ...           2 years ago
  • 1.15.0                                ...           2 years ago
  • 1.14.1                                ...           2 years ago
  • 1.14.0                                ...           2 years ago
  • 1.13.16                                ...           2 years ago
  • 1.13.17                                ...           2 years ago
  • 1.13.15                                ...           2 years ago
  • 1.13.14                                ...           2 years ago
  • 1.13.13                                ...           2 years ago
  • 1.13.12                                ...           2 years ago
  • 1.13.11                                ...           2 years ago
  • 1.13.10                                ...           2 years ago
  • 1.13.9                                ...           2 years ago
  • 1.13.8                                ...           2 years ago
  • 1.13.7                                ...           2 years ago
  • 1.13.6                                ...           2 years ago
  • 1.13.5                                ...           2 years ago
  • 1.13.4                                ...           2 years ago
  • 1.13.3                                ...           2 years ago
  • 1.13.2                                ...           2 years ago
  • 1.13.1                                ...           2 years ago
  • 1.13.0                                ...           2 years ago
  • 1.12.19                                ...           2 years ago
  • 1.12.17                                ...           2 years ago
  • 1.12.16                                ...           2 years ago
  • 1.12.15                                ...           2 years ago
  • 1.12.14                                ...           2 years ago
  • 1.12.13                                ...           2 years ago
  • 1.12.12                                ...           2 years ago
  • 1.12.11                                ...           2 years ago
  • 1.12.10                                ...           2 years ago
  • 1.12.9                                ...           2 years ago
  • 1.12.8                                ...           2 years ago
  • 1.12.7                                ...           2 years ago
  • 1.12.6                                ...           2 years ago
  • 1.12.4                                ...           2 years ago
  • 1.12.3                                ...           2 years ago
  • 1.12.2                                ...           2 years ago
  • 1.12.1                                ...           2 years ago
  • 1.12.0                                ...           2 years ago
  • 1.11.8                                ...           2 years ago
  • 1.11.7                                ...           2 years ago
  • 1.11.5                                ...           2 years ago
  • 1.11.4                                ...           2 years ago
  • 1.11.3                                ...           2 years ago
  • 1.11.2                                ...           2 years ago
  • 1.11.1                                ...           2 years ago
  • 1.11.0                                ...           2 years ago
  • 1.10.7                                ...           2 years ago
  • 1.10.6                                ...           2 years ago
  • 1.10.5                                ...           2 years ago
  • 1.10.3                                ...           2 years ago
  • 1.10.2                                ...           2 years ago
  • 1.10.1                                ...           2 years ago
  • 1.10.0                                ...           2 years ago
  • 1.9.4                                ...           2 years ago
  • 1.9.3                                ...           2 years ago
  • 1.9.2                                ...           2 years ago
  • 1.9.1                                ...           2 years ago
  • 1.8.7                                ...           2 years ago
  • 1.9.0                                ...           2 years ago
  • 1.8.6                                ...           2 years ago
  • 1.8.5                                ...           2 years ago
  • 1.8.4                                ...           2 years ago
  • 1.8.3                                ...           2 years ago
  • 1.8.2                                ...           2 years ago
  • 1.8.1                                ...           2 years ago
  • 1.7.0                                ...           2 years ago
  • 1.6.4                                ...           2 years ago
  • 1.6.3                                ...           2 years ago
  • 1.6.2                                ...           2 years ago
  • 1.6.1                                ...           2 years ago
  • 1.6.0                                ...           2 years ago
  • 1.5.0                                ...           2 years ago
  • 1.4.1                                ...           2 years ago
  • 1.4.0                                ...           2 years ago
  • 1.3.1                                ...           2 years ago
  • 1.3.0                                ...           2 years ago
  • 1.2.4                                ...           2 years ago
  • 1.2.3                                ...           3 years ago
  • 1.2.2                                ...           3 years ago
  • 1.2.1                                ...           3 years ago
  • 1.2.0                                ...           3 years ago
  • 1.1.1                                ...           3 years ago
  • 1.1.0                                ...           3 years ago
  • 1.0.2                                ...           3 years ago
  • 1.0.1                                ...           3 years ago
  • 1.0.0                                ...           3 years ago
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 1
Dependencies (16)
Dev Dependencies (11)

Copyright 2014 - 2016 © taobao.org |