Modules
- @switchless/util
-
Helper and middleware function for node and express based apps.
- helper
- middleware
@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
-
helper
-
.formatNumber(number, number_format, precision) ⇒
string
-
.logger(level) ⇒
object
-
.formatNumber(number, number_format, precision) ⇒
string
switchlessUtil.helper.formatNumber(number, number_format, precision) ⇒ 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
Param | Type |
---|---|
number | * |
number_format | * |
precision | * |
object
switchlessUtil.helper.logger(level) ⇒ Kind: static method of helper
Param | Type |
---|---|
level | string |
middleware
-
middleware
-
.requestLogger(req, res, next) ⇒
callback
-
.JWTAuth(secret) ⇒
function
-
.sanitizeHTML(req, res, next) ⇒
callback
-
.rateLimit(redis_host) ⇒
function
-
.requestLogger(req, res, next) ⇒
callback
switchlessUtil.middleware.requestLogger(req, res, next) ⇒ Kind: static method of middleware
Param | Type |
---|---|
req | * |
res | * |
next | * |
function
switchlessUtil.middleware.JWTAuth(secret) ⇒ Kind: static method of middleware
Param | Type |
---|---|
secret | * |
callback
switchlessUtil.middleware.sanitizeHTML(req, res, next) ⇒ Kind: static method of middleware
Param | Type |
---|---|
req | * |
res | * |
next | * |
function
switchlessUtil.middleware.rateLimit(redis_host) ⇒ Kind: static method of middleware
Param | Type |
---|---|
redis_host | string |