3.3.0 • Published 3 years ago

@switchless-io/util v3.3.0

Weekly downloads
27
License
MIT
Repository
github
Last release
3 years ago

Modules

@switchless/util

Helper and middleware function for node and express based apps.

Example
Installation

npm install @switchless-io/util

Usage

const switchlessUtil = require('@switchless/util')

helper

switchlessUtil.helper.formatNumber(number, number_format, precision) ⇒ string

number - the number to be formatted number_format - what format do you want the number to be formatted in. precision - if the number has decimals, then what precision do you want to show

egs of number format

  • indian_thousand
  • indian_lakh
  • indian_crore
  • us_thousand
  • us_million
  • us_billion

precision - takes in any integer. Most commonly used - 1 or 2

Kind: static method of helper

ParamType
number*
number_format*
precision*

switchlessUtil.helper.logger(level) ⇒ object

Kind: static method of helper

ParamType
levelstring

middleware

switchlessUtil.middleware.requestLogger(req, res, next) ⇒ callback

Kind: static method of middleware

ParamType
req*
res*
next*

switchlessUtil.middleware.JWTAuth(secret) ⇒ function

Kind: static method of middleware

ParamType
secret*

switchlessUtil.middleware.sanitizeHTML(req, res, next) ⇒ callback

Kind: static method of middleware

ParamType
req*
res*
next*

switchlessUtil.middleware.rateLimit(redis_host) ⇒ function

Kind: static method of middleware

ParamType
redis_hoststring