Options
All
  • Public
  • Public/Protected
  • All
Menu

External module "src/helpers/utils"

Index

Variables

Const IdValues

IdValues: string[] = ["id","userId","organizationId","primaryEmail","apiKeyId","apiKeyOrganizationId"]

MySQL columns which are for int IDs

Const boolValues

boolValues: string[] = ["twoFactorEnabled","prefersReducedMotion","prefersColorSchemeDark","used","isVerified","forceTwoFactor","autoJoinDomain","onlyAllowDomain","isActive","checkLocationOnLogin"]

MySQL columns which are booleans

Const dateValues

dateValues: string[] = ["createdAt","updatedAt","lastFiredAt","expiresAt"]

MySQL columns which are datetime values

Const hashIds

hashIds: Hashids = new Hashids(HASH_IDS,10,"abcdefghijklmnopqrstuvwxyz1234567890")

Const jsonValues

jsonValues: string[] = ["data"]

MySQL columns which are JSON values

Const readOnlyValues

readOnlyValues: string[] = ["createdAt","id","jwtApiKey","userId","organizationId"]

MySQL columns which are read-only

Functions

Const anonymizeIpAddress

  • anonymizeIpAddress(ipAddress: string): string
  • Anonymize an IP address

    Parameters

    • ipAddress: string

    Returns string

Const capitalizeEachFirstLetter

  • capitalizeEachFirstLetter(string: string): string
  • Capitalize each first letter in a string

    Parameters

    • string: string

    Returns string

Const capitalizeFirstAndLastLetter

  • capitalizeFirstAndLastLetter(string: string): string
  • Capitalize the first letter of each word in a string

    Parameters

    • string: string

    Returns string

Const capitalizeFirstLetter

  • capitalizeFirstLetter(string: string): string
  • Capitalize the first letter of a string

    Parameters

    • string: string

    Returns string

Const createSlug

  • createSlug(name: string): string
  • Parameters

    • name: string

    Returns string

Const dateToDateTime

  • dateToDateTime(date: Date): string
  • Convert a JS Date to MySQL-compatible datetime

    Parameters

    • date: Date

    Returns string

Const deleteSensitiveInfoUser

  • deleteSensitiveInfoUser(user: User): User
  • Delete any sensitive information for a user like passwords and tokens

    Parameters

    Returns User

Const dnsResolve

  • dnsResolve(hostname: string, recordType: "A" | "AAAA" | "ANY" | "CNAME" | "MX" | "NAPTR" | "NS" | "PTR" | "SOA" | "SRV" | "TXT"): Promise<string[] | MxRecord[] | NaptrRecord[] | SoaRecord | SrvRecord[] | string[][] | dns.AnyRecord[]>
  • Parameters

    • hostname: string
    • recordType: "A" | "AAAA" | "ANY" | "CNAME" | "MX" | "NAPTR" | "NS" | "PTR" | "SOA" | "SRV" | "TXT"

    Returns Promise<string[] | MxRecord[] | NaptrRecord[] | SoaRecord | SrvRecord[] | string[][] | dns.AnyRecord[]>

Const generateHashId

  • generateHashId(id: string): string
  • Parameters

    • id: string

    Returns string

Const getCodeFromRequest

  • getCodeFromRequest(req: Request): any
  • Parameters

    • req: Request

    Returns any

Const hashIdToId

  • hashIdToId(id: string | number): string
  • Parameters

    • id: string | number

    Returns string

Const includesDomainInCommaList

  • includesDomainInCommaList(commaList: string, value: string): boolean
  • Parameters

    • commaList: string
    • value: string

    Returns boolean

Const joiValidate

  • joiValidate(schemaMap: SchemaMap, data: any): boolean
  • Parameters

    • schemaMap: SchemaMap
    • data: any

    Returns boolean

Const localsToTokenOrKey

  • Parameters

    • res: Response

    Returns string | ApiKeyResponse

Const organizationUsernameToId

  • organizationUsernameToId(id: string): Promise<string>
  • Parameters

    • id: string

    Returns Promise<string>

Const removeFalsyValues

  • removeFalsyValues(value: any): any
  • Parameters

    • value: any

    Returns any

Const safeRedirect

  • safeRedirect(req: Request, res: Response, url: string): void | Response
  • Parameters

    • req: Request
    • res: Response
    • url: string

    Returns void | Response

Const userUsernameToId

  • userUsernameToId(id: string, tokenUserId: string): Promise<string>
  • Parameters

    • id: string
    • tokenUserId: string

    Returns Promise<string>

Generated using TypeDoc