Introducing Socket Firewall: Free, Proactive Protection for Your Software Supply Chain.Learn More
Socket
Book a DemoInstallSign in
Socket

@jackdouglas/ts-utilities

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@jackdouglas/ts-utilities

Jack's Utilities & Functions

latest
npmnpm
Version
1.0.8
Version published
Maintainers
1
Created
Source

Jack's Utility Module

Mostly Notify Code

Documentation for utilities

Validation Options

NamePurposeTypeDefault
exactRequires the object to match exactly to the contraint keys providedbooleanfalse
requiredRequires the object to contain at least the items in the arraystring[]null
whitelistedRequires the object to contain only items that are in the arraystring[]null

Validation Constraints

NamePurposeTypeDefault
emailRequires the specified value pass the email specfic regexbooleanfalse
lowercaseRequires the value to be lowercase onlybooleanfalse
uppercaseRequires the value to be uppercase onlybooleanfalse
numberRequires the value to be number onlybooleanfalse
lengthRequires the value to meet the min or max length{ min?: number, max?: number }null
nullableSpecifies if the value is allow to be unset or nullbooleantrue
trimRemoves whitespace from the stringbooleantrue

Logging

Traditional logging

Also bundled is a logging utility

This logging utility exposes the following methods

NamePurpose
Logconsole.log but with the twist of color,time and other logger benefits
Errorconsole.error same as log with different colors, and registers as an error on our error tracking
Debugconsole.log nearly the same as Log but with the twist of an env variable check for DEBUG="jack:*" which will allow the output of this log line

Request logging

Included is an express middleware to handle logging of request details

Things that get logged when a request is received

• Request Method
• Request Path
• Status Code
• Response Time in ms
• Client IP Address
Response Size B/KB/MB/GB soon

Request Responses

This request utility exposes the following methods

NameResponse FormatParameters
Success{ success: true, data }res: Response, status: number, data?: any
Failed{ error: true, code, data }res: Response, status: number, code: string, data?: any
Missing{ error: true, code: 'route_not_found' }res: Response
Catch{ error: true, code: 'catch', data }res: Response, data?: any

FAQs

Package last updated on 14 Aug 2020

Did you know?

Socket

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