Options
All
  • Public
  • Public/Protected
  • All
Menu

@echelon-solutions/aws-event-sourcing

Index

Type aliases

Property

Property: "DYNAMODB_TABLE" | "AWS_REGION"

Variables

Const AWS

AWS: any = (process.env.IS_OFFLINE)? require('aws-sdk'): AWSXRay.captureAWS(require('aws-sdk'))

Const apiHandler

apiHandler: Handler = Serverless(app)

Const app

app: Express = defaultApp()

Const defaultMiddlewares

defaultMiddlewares: ((Anonymous function) | (Anonymous function))[] = [(req: express.Request, res: express.Response, next: express.NextFunction) => {xray('error', 'CLIENT | 404 Not Found', true)res.status(404).send()},(error: Error, req: express.Request, res: express.Response, next: express.NextFunction) => {if (error.message === 'Invalid request') {xray('error', `CLIENT | ${error.message}`, true)res.status(400).json({message: error.message})} else {console.error(error)xray('error', `SERVER | ${error.message}`, true)res.status(500).json({message: 'Internal server error'})}},AWSXRay.express.closeSegment()]

For the following middlewares to work properly, they must be the last middlewares injected by app.use()

Const dynamo

dynamo: DocumentClient = (process.env.IS_OFFLINE)? new AWS.DynamoDB.DocumentClient({ region: 'localhost', endpoint: 'http://localhost:8000' }) as DynamoDB.DocumentClient: new AWS.DynamoDB.DocumentClient({ apiVersion: '2012-08-10', region: loadProperty('AWS_REGION') }) as DynamoDB.DocumentClient

Let localDatabase

localDatabase: any

Const s3

s3: S3 = new AWS.S3({ apiVersion: '2006-03-01', region: loadProperty('AWS_REGION') }) as S3

Const tableName

tableName: "domain-test" = process.env.DYNAMODB_TABLE = 'domain-test'

Functions

defaultApp

  • defaultApp(): express.Express

Const handler

  • handler(event: any, context: any, callback: any): void | Promise<APIGatewayProxyResult> | Promise<void>
  • handler(event: any, context: any, callback: any): void

Const handlerRouter

  • handlerRouter(event: any, context: any, callback: any, handlers: { api?: APIGatewayProxyHandler; scheduled?: ScheduledHandler; stream?: DynamoDBStreamHandler; topic?: SNSHandler }): void | Promise<APIGatewayProxyResult> | Promise<void>
  • A Lambda handler router that determines the proper handler to use based on the type of the received event

    Parameters

    • event: any
    • context: any
    • callback: any
    • handlers: { api?: APIGatewayProxyHandler; scheduled?: ScheduledHandler; stream?: DynamoDBStreamHandler; topic?: SNSHandler }
      • Optional Readonly api?: APIGatewayProxyHandler
      • Optional Readonly scheduled?: ScheduledHandler
      • Optional Readonly stream?: DynamoDBStreamHandler
      • Optional Readonly topic?: SNSHandler

    Returns void | Promise<APIGatewayProxyResult> | Promise<void>

loadProperty

  • loadProperty(property: Property): string

loadPropertyOptional

  • loadPropertyOptional(property: Property): string | undefined

Const streamHandler

  • streamHandler(event: DynamoDBStreamEvent, context: Context, callback: Callback<void>): Promise<void>

xray

  • xray(key: string, value: string, searchable: boolean): void
  • Adds an AWS XRAY log annotation that is searchable/filterable (or not) in the console.

    Parameters

    • key: string
    • value: string
    • searchable: boolean

    Returns void

Generated using TypeDoc