1.0.8 • Published 4 years ago

@jackdouglas/ts-utilities v1.0.8

Weekly downloads
-
License
-
Repository
-
Last release
4 years ago

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
1.0.8

4 years ago

1.0.7

4 years ago

1.0.6

4 years ago

1.0.5

4 years ago

1.0.4

4 years ago

1.0.3

4 years ago

1.0.2

4 years ago

1.0.1

4 years ago

1.0.0

4 years ago