1.2.25 • Published 3 years ago

@dustinrouillard/fastify-utilities v1.2.25

Weekly downloads
2
License
MIT
Repository
-
Last release
3 years ago

Dustin's Utilities Module


Documentation for utilities

Validation

Validation Options

NamePurposeTypeDefault
strictRequires the object to contain only items that constraints exist forbooleanfalse
requiredRequires the object to contain at least the items in the arraystring[][]

Validation Constraints

NamePurposeTypeDefault
emailRequires the specified value pass the email specfic regexbooleanfalse
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
allowedList of strings or numbers that are allowed(string \| number)[]null
casingDesired casing to validate the item forstring (any, upper, lower)null
typeIf specified a type the typeof will be comparedstringnull

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="dstn:*" which will allow the output of this log line

Changing/disabling colors

Included is a function to change the configuation of the logger, such as the colors or to disable them altogether.

The configurable options are

NameDefault
timestampColorgray
logColorgreen
errorColorredBright
debugColorblueBright
disableColorsfalse
debugAnnotationdstn

Request logging

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


Request Responses

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.2.23

3 years ago

1.2.24

3 years ago

1.2.22

3 years ago

1.2.25

3 years ago

1.2.19

3 years ago

1.2.20

3 years ago

1.2.21

3 years ago

1.2.18

3 years ago

1.2.12

3 years ago

1.2.13

3 years ago

1.2.10

3 years ago

1.2.11

3 years ago

1.2.16

3 years ago

1.2.17

3 years ago

1.2.14

3 years ago

1.2.15

3 years ago

1.2.8

3 years ago

1.2.9

3 years ago

1.2.7

3 years ago

1.2.6

3 years ago

1.2.0

4 years ago

1.2.1

4 years ago

1.0.9

4 years ago

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