idea-aws
    Preparing search index...

    Class ResourceControllerAbstract

    An abstract class to inherit to manage API requests (AWS API Gateway) in an AWS Lambda function.

    Hierarchy (View Summary)

    Index

    Constructors

    Properties

    auth0User: Auth0User
    authorization: string
    body: any
    claims: any
    clientBundle: string = null
    clientPlatform: string = '?'
    clientVersion: string = '?'
    cognitoUser: CognitoUser
    currentLang: string
    defaultLang: string
    event: APIGatewayProxyEventV2 | APIGatewayProxyEvent
    httpMethod: string
    initError?: Error
    logger: LambdaLogger = ...
    logRequestsWithKey: string
    metrics: CloudWatchMetrics
    path: string
    pathParameters: any
    principalId: string
    project: string = PROJECT
    queryParams: any
    resource: string = RESOURCE
    resourceId: string
    resourcePath: string
    returnHeaders: Record<string, string> = ...
    returnStatusCode?: number
    stage: string = STAGE
    templateMatcher: RegExp = ...
    tracer: Tracer
    tracerLambdaSegment: any
    tracerRCSegment: any
    translations: any

    Methods

    • Whether the current request comes from an internal API request, i.e. it was invoked by another controller.

      Returns boolean

      don't run a Lambda from another Lambda (bad practice)

    • Parameters

      • limitBodyArrayDisplay: boolean = false

      Returns Record<string, any>

    • Get the current log level for the current Lambda function's logger. Note: "FATAL" means that no log will be printed.

      Returns "TRACE" | "DEBUG" | "INFO" | "WARN" | "ERROR" | "FATAL"

    • Force the parsing of a query parameter as an array of strings.

      Parameters

      • paramName: string

      Returns string[]

    • Force the parsing of a query parameter as a boolean.

      Parameters

      • paramName: string

      Returns boolean

    • Load a shared resource in the back-end (translation, template, etc.). Search for the specified file path in both the Lambda function's main folder and the layers folder.

      Parameters

      • filePath: string

      Returns string

    • Load the translations from the shared resources and set them with a fallback language.

      Parameters

      • lang: string
      • OptionaldefLang: string

      Returns void

    • Publish the CloudWatch metrics (default and custom-defined) at the end of a reqeust.

      Parameters

      • statusCode: number
      • Optionalerror: any

      Returns void

    • Set the log level for the current Lambda function's logger.

      Parameters

      • logLevel: "TRACE" | "DEBUG" | "INFO" | "WARN" | "ERROR" | "FATAL"

      Returns void

    • Check whether shared resource exists in the back-end (translation, template, etc.). Search for the specified file path in both the Lambda function's main folder and the layers folder.

      Parameters

      • filePath: string

      Returns boolean

    • Store the log associated to the request (no response/error handling).

      Parameters

      • succeeded: boolean

      Returns Promise<void>

    • Get a translated term by key, optionally interpolating variables (e.g. {{user}}). If the term doesn't exist in the current language, it is searched in the default language.

      Parameters

      • key: string
      • OptionalinterpolateParams: any

      Returns string