Options
All
  • Public
  • Public/Protected
  • All
Menu
     

Class DBRequest

A REST API Object for Database Endpoint Handling & Documentation.

Hierarchy

Indexable

[routeName: string]: object

A REST API Object for Database Endpoint Handling & Documentation.

  • [method: string]: function

Index

Constructors

constructor

  • Creates an instance of DBRequest.

    Parameters

    • Name: string

      The name of the request route

    • Configs: CLRouteDB

      The configurations for the request route

    Returns DBRequest

Properties

Name

Name: string

Requests

Requests: OrderedMap<string, RouteDB>

Private Sanitzers

Sanitzers: CLSanitizers

Private Defaults

Defaults: object

Type declaration

  • [defaultName: string]: any

Methods

Error

  • Error(req: ExRequest, res: ExResponse, err: Error): void
  • Sends an Error response to the Client

    Parameters

    • req: ExRequest

      The Client HTTP Request instance

    • res: ExResponse

      The Server HTTP Response instance

    • err: Error

      The Error instance

    Returns void

Limit

  • Limit(req: ExRequest, res: ExResponse): void
  • Sends an Limit response to the Client when a limit-rate has been reached

    Parameters

    • req: ExRequest

      The Client HTTP Request instance

    • res: ExResponse

      The Server HTTP Response instance

    Returns void

MS

  • MS(msg: string, acct: string): string
  • Renders a message specific to a User account via a provided template.

    Parameters

    • msg: string

      A sprintf-style string template.

    • acct: string

      A username, email, etc.

    Returns string

    A formatted message directed to a specific User.

OK

  • OK(res: ExResponse, msg: string, usr: User, acct: string, bdy: Query, cde: number, next: ExNext): void
  • Sends a User-Info Server Response to a Client (HTTP or Socket).

    Parameters

    • res: ExResponse

      An HTTP or Socket instance.

    • msg: string

      A message regarding the response.

    • usr: User

      The user-info object.

    • acct: string

      A username, email, etc.

    • bdy: Query

      The body object from the request.

    • cde: number

      The payload status code (this is NOT the HTTP status).

    • next: ExNext

      The next step in the process.

    Returns void

SN

  • SN(res: exResponse, pay: Payload, opts: Options, status: number): void
  • Sends a Server Response to a Client (HTTP or Socket)

    Parameters

    • res: exResponse

      An HTTP or Socket instance

    • pay: Payload

      The "payload" object to send to the Client

    • opts: Options

      The "options" object, which includes the params, query, body, etc.

    • status: number

      The HTTP status code

    Returns void

ER

  • ER(res: ExResponse, hnd: Errors.HTTP_MSG, err: Error, acct: string, qry: Options, all?: boolean, noSend?: boolean): void | Payload
  • Sends an Error Response to a Client (HTTP or Socket).

    Parameters

    • res: ExResponse

      An HTTP or Socket instance.

    • hnd: Errors.HTTP_MSG

      The appropriate Error Response handler.

    • err: Error

      The Error instance.

    • acct: string

      A username, email, etc.

    • qry: Options

      The query object from the request.

    • Default value all: boolean = false

      If true, send to all subscribers.

    • Default value noSend: boolean = false

      If true, do NOT send, just return the result.

    Returns void | Payload

    If noSend is true, this result object is returned.

TimerHash

  • TimerHash(): string
  • Generates a random, unique HASH for identifying each Timer

    see

    TimerStart

    see

    TimerEnd

    Returns string

    A random, unique HASH identifier

TimerStart

  • TimerStart(): string
  • Starts a Timer until explicity ended with TimerEnd()

    see

    TimerHash

    see

    TimerEnd

    Returns string

    A generated HASH identifier

TimerEnd

  • TimerEnd(hash: string): number
  • Ends the Timer and returns the duration

    see

    TimerHash

    see

    TimerStart

    Parameters

    • hash: string

      A HASH identifier (gererated by TimerHash())

    Returns number

    The duration of the timed execution

Clause

  • Sanitizes & Formats each Parameter in an Endpoint's clause

    Parameters

    • name: string

      The name of this Endpoint

    • method: HMETHOD

      The method of this Endpoint

    • cls: object

      An object literal of parameter clauses

      • [paramName: string]: string
    • gnp: CLParameters

      An object literal of GNParam instances for each parameter

    Returns any

Parse

  • Parse(RQ: Method, RT: object | object[], QY: Query): object | object[]
  • Parses a request result for consumption by the client.

    Parameters

    • RQ: Method

      A request-method handler.

    • RT: object | object[]

      The result of the request.

    • QY: Query

      The query/body of the request.

    Returns object | object[]

Path

  • Path(...args: string[]): string
  • Builds a full-path of endpoint paths in relation to this request.

    Parameters

    • Rest ...args: string[]

      The strings to use in the path.

    Returns string

Cast

  • Cast(RQ: Method): MySQL.TypeCast
  • Builds a SQL casting function to convert row values to determined types for a request method handler.

    Parameters

    • RQ: Method

      A request-method handler.

    Returns MySQL.TypeCast

Opts

  • Opts(cls: object): object
  • Takes a request query/body and converts any ;-separated lists into Arrays.

    Parameters

    • cls: object

      The request clause.

      • [paramName: string]: string

    Returns object

    • [paramName: string]: string | string[]

Init

  • Initializes all Data-Endpoints

    Returns DBRequest