Options
All
  • Public
  • Public/Protected
  • All
Menu

Class RouterEvent

Input to the HTTP router. Based on the ProxyEvent but enriched.

Hierarchy

  • RouterEvent

Index

Properties

body

body: any

Request body (JSON.parsed if possible).

bodyRaw

bodyRaw: any

Unparsed request body.

cookies

cookies: {}

Parsed Cookie header.

Type declaration

  • [name: string]: string

headers

headers: {}

All headers of the request with only the first value. They are stored here in their original form but the spec requires that header keys are treated as case-insensitive. Use headersLowerCase for easier retrieval.

Type declaration

  • [key: string]: string

headersLowerCase

headersLowerCase: {}

All headers of the request with only the first value, keys in lower case.

Type declaration

  • [key: string]: string

httpMethod

httpMethod: string

GET, POST, PUT, etc...

meta

meta: {}

A work area for Routes to add properties to. This can be used to sneak information from routes that preprocess to later routes; for example auth credentials.

Type declaration

  • [name: string]: any

multiValueHeaders

multiValueHeaders: {}

All headers of the request including all values. They are stored here in their original form but the spec requires that header keys are treated as case-insensitive. Use multiValueHeadersLowerCase for easier retrieval.

Type declaration

  • [key: string]: string[]

multiValueHeadersLowerCase

multiValueHeadersLowerCase: {}

All headers of the request including all values, keys in lower case.

Type declaration

  • [key: string]: string[]

multiValueQueryStringParameters

multiValueQueryStringParameters: {}

The parsed URI query parameters including all values.

Type declaration

  • [key: string]: string[]

path

path: string

The request URI path. eg: /foo/bar

pathParameters

pathParameters: {}

The parsed URI path parameters.

Type declaration

  • [key: string]: string

queryStringParameters

queryStringParameters: {}

The parsed URI query parameters with only their first value.

Type declaration

  • [key: string]: string

requestContext

requestContext: { accountId: string; apiId: string; authorizer?: {}; httpMethod: string; identity: { accessKey: string; accountId: string; apiKey: string; apiKeyId: string; caller: string; cognitoAuthenticationProvider: string; cognitoAuthenticationType: string; cognitoIdentityId: string; cognitoIdentityPoolId: string; sourceIp: string; user: string; userAgent: string; userArn: string }; path: string; requestId: string; requestTimeEpoch: number; resourceId: string; resourcePath: string; stage: string }

Type declaration

  • accountId: string
  • apiId: string
  • Optional authorizer?: {}
    • [name: string]: any
  • httpMethod: string
  • identity: { accessKey: string; accountId: string; apiKey: string; apiKeyId: string; caller: string; cognitoAuthenticationProvider: string; cognitoAuthenticationType: string; cognitoIdentityId: string; cognitoIdentityPoolId: string; sourceIp: string; user: string; userAgent: string; userArn: string }
    • accessKey: string
    • accountId: string
    • apiKey: string
    • apiKeyId: string
    • caller: string
    • cognitoAuthenticationProvider: string
    • cognitoAuthenticationType: string
    • cognitoIdentityId: string
    • cognitoIdentityPoolId: string
    • sourceIp: string
    • user: string
    • userAgent: string
    • userArn: string
  • path: string
  • requestId: string
  • requestTimeEpoch: number
  • resourceId: string
  • resourcePath: string
  • stage: string

stageVariables

stageVariables: {}

Configuration attributes associated with a deployment stage of an API.

Type declaration

  • [key: string]: string

Methods

blacklistQueryStringParameters

  • blacklistQueryStringParameters(...params: string[]): void
  • Require that the given query parameters are not set. If any parameter in this list is set a RestError is thrown.

    Parameters

    • Rest ...params: string[]

    Returns void

requireHeader

  • requireHeader(field: string): void
  • requireHeader(field: string, values: string[], explanation?: string): void
  • requireHeader(field: string, validator: (value: string) => boolean, explanation?: string): void
  • Require that the given header field is set.

    Parameters

    • field: string

    Returns void

  • Require that the given header field is set and has one of the given values.

    Parameters

    • field: string
    • values: string[]
    • Optional explanation: string

    Returns void

  • Require that the given header field is set and satisfies the validator function.

    Parameters

    • field: string
    • validator: (value: string) => boolean
        • (value: string): boolean
        • Parameters

          • value: string

          Returns boolean

    • Optional explanation: string

    Returns void

requireQueryStringParameter

  • requireQueryStringParameter(param: string): void
  • requireQueryStringParameter(param: string, values: string[], explanation?: string): void
  • requireQueryStringParameter(param: string, validator: (value: string) => boolean, explanation?: string): void
  • Require that the given query parameter is set. If the parameter is not set a RestError is thrown.

    Parameters

    • param: string

    Returns void

  • Require that the given query parameter is set and has one of the given values. If the parameter is not set or does not take on one of the given values a RestError is thrown.

    Parameters

    • param: string
    • values: string[]
    • Optional explanation: string

    Returns void

  • Require that the given query parameter is set and satisfies the validator function. If the parameter is not set or does not satisfy the given validator function a RestError is thrown.

    Parameters

    • param: string
    • validator: (value: string) => boolean
        • (value: string): boolean
        • Parameters

          • value: string

          Returns boolean

    • Optional explanation: string

    Returns void

validateBody

whitelistQueryStringParameters

  • whitelistQueryStringParameters(...params: string[]): void
  • Require that only the given query parameters are set. No parameter in this list has to be set, but if any parameter is set that is not in this list a RestError will be thrown.

    Parameters

    • Rest ...params: string[]

    Returns void

Generated using TypeDoc