Skip to main content

Module: strategies/utils

Functions

checkType

checkType(object, key, type, nullable?, defaultValue?): any

Checks a key if an object for a specified type using the typeof operator. If type is "string" will also check, the value is not empty.

If nullable and a default is given, this will be returned, if the field is undefined (NOT if the type check was unsuccessful)

Parameters

NameTypeDescription
objectobjectThe object in which to check the key
keystringThe key in the object in which to check the type
type"string" | "number" | "bigint" | "boolean" | "symbol" | "undefined" | "object" | "function"The Expected type of the field. Must be one of the types returned by the typeof operator
nullable?booleanSet to true if the field may be undefined
defaultValue?anyIf undefined, this value will be returned instead

Returns

any

The field value if the type check was successful, if undefined and nullable the default value

Throws

Error with according message if the type check wasn't successful

Defined in

login-service/src/strategies/utils.ts:30


ensureState

ensureState(res): void

Parameters

NameType
resResponse<any, Record<string, any>>

Returns

void

Defined in

login-service/src/strategies/utils.ts:3