Options
All
  • Public
  • Public/Protected
  • All
Menu

Index

Type aliases

OnNatsEventMessageHandler

OnNatsEventMessageHandler<TEvent>: (context: INatsEventMessageHandlerContext<TEvent>) => Promise<void>

Handles a message.

param

The context.

Type parameters

  • TEvent: any = any

Type declaration

Variables

Const BCRYPT_ROUNDS

BCRYPT_ROUNDS: undefined | string = ...

The number of rounds for bcrypt hashing.

Const JWT_SECRET

JWT_SECRET: undefined | string = ...

The secret for signing and validating JWT.

Const NATS_CLUSTER_ID

NATS_CLUSTER_ID: undefined | string = ...

The name of the cluster, that contains this and the other microservices.

Const NATS_GROUP

NATS_GROUP: undefined | string = ...

The name of the pod group / kubernetes deployment.

Const NATS_URL

NATS_URL: undefined | string = ...

The URL to the NATS server.

Const POD_NAME

POD_NAME: undefined | string = ...

The name of the POD, which is used as client ID for NATS, e.g.

Const stan

stan: NatsClient = ...

A default NATS client instance.

Functions

checkPassword

  • checkPassword(password: string, hash: string): Promise<boolean>
  • Checks if a password matching a hash.

    Parameters

    • password: string

      The unhashed password.

    • hash: string

      The password hash.

    Returns Promise<boolean>

    Promise, that indicates if password does match or not.

checkPasswordSync

  • checkPasswordSync(password: string, hash: string): boolean
  • Checks (synchronous) if a password matching a hash.

    Parameters

    • password: string

      The unhashed password.

    • hash: string

      The password hash.

    Returns boolean

    Promise, that indicates if password does match or not.

hashPassword

  • hashPassword(password: string): Promise<string>
  • Hashes a password string.

    Parameters

    • password: string

      The unhashed password.

    Returns Promise<string>

    The promise with the password hash.

hashPasswordSync

  • hashPasswordSync(password: string): string
  • Hashes a password string synchronous.

    Parameters

    • password: string

      The unhashed password.

    Returns string

    The password hash.

signJWT

  • signJWT(decodedToken: any, options?: Optional<SignOptions>): string
  • Creates a JWT from an object.

    Parameters

    • decodedToken: any

      The token as object.

    • Optional options: Optional<SignOptions>

    Returns string

    The JWT.

verifyJWT

  • verifyJWT<TToken>(token: string): TToken | false
  • Verifies a JWT and returns it decoded version, if succeeded.

    Type parameters

    • TToken: unknown = any

    Parameters

    • token: string

      The token as string.

    Returns TToken | false

    The decoded token, or (false), if verification failed.

withJWT

  • Creates a new Express middleware, that checks for a valid JWT.

    Parameters

    Returns RequestHandler

    The new middleware.

Generated using TypeDoc