This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import sqsRecordGenerator from '@tests/utilities/sqsRecordFactory'; | |
| import { SQSEvent, SQSRecord } from 'aws-lambda'; | |
| export default (events?: SQSRecord[]): SQSEvent => ({ | |
| Records: events || [sqsRecordGenerator()], | |
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import { v4 as uuidv4 } from 'uuid'; | |
| import { SQSRecord } from 'aws-lambda'; | |
| const now = Math.round((new Date()).getTime() / 1000).toString(); | |
| export default (params?: Partial<SQSRecord>): SQSRecord => ({ | |
| messageId: uuidv4(), | |
| receiptHandle: uuidv4(), | |
| body: '', |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const env = { | |
| AWS_REGION: 'local', | |
| AWS_ACCESS_KEY: 'fake_key', | |
| AWS_SECRET_KEY: 'fake_secret', | |
| }; | |
| process.env = { | |
| ...process.env, | |
| ...env, | |
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import { ClientConfiguration, DocumentClient } from 'aws-sdk/clients/dynamodb'; | |
| const config: ClientConfiguration = { | |
| region: process.env.AWS_REGION, | |
| accessKeyId: process.env.AWS_ACCESS_KEY, | |
| secretAccessKey: process.env.AWS_SECRET_KEY, | |
| }; | |
| if (['test'].includes(process.env.NODE_ENV)) { | |
| config.endpoint = 'http://localhost:8000'; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import { DocumentClient } from 'aws-sdk/clients/dynamodb'; | |
| import DynamoDB from '@dazn/lambda-powertools-dynamodb-client'; | |
| /* | |
| * This checks the environment and either outputs a raw DynamoDocumentClient for offline testing | |
| * or it outputs the dazn-powertools DynamoDocumentClient that adds context and tracing | |
| */ | |
| export default ['test'].includes(process.env.NODE_ENV) | |
| ? new DocumentClient({ | |
| region: process.env.AWS_REGION, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // eslint-disable-next-line @typescript-eslint/explicit-function-return-type | |
| module.exports = async () => { | |
| /* eslint-disable global-require */ | |
| const serverless = new (require('serverless'))(); | |
| await serverless.init(); | |
| const service = await serverless.variables.populateService(); | |
| const resources = service.resources.Resources; | |
| const tables = Object.keys(resources) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| module.exports = { | |
| setupFiles: ['./tests/setup/setEnvironment.js'], | |
| transform: { | |
| '^.+\\.ts?$': 'babel-jest', | |
| }, | |
| moduleNameMapper: { | |
| '^@repositories/(.*)$': '<rootDir>/src/repositories/$1', | |
| '^@clients/(.*)$': '<rootDir>/src/clients/$1', | |
| '^@transformers/(.*)$': '<rootDir>/src/transformers/$1', | |
| '^@src/(.*)$': '<rootDir>/src/$1', |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| { | |
| "Version": "2012-10-17", | |
| "Statement": [ | |
| { | |
| "Sid": "VisualEditor0", | |
| "Effect": "Allow", | |
| "Action": [ | |
| "lambda:CreateFunction", | |
| "lambda:ListVersionsByFunction", | |
| "s3:CreateBucket", |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import { APIGatewayProxyHandler } from ‘aws-lambda'; | |
| import { echo } from ‘@queries/exampleQuery'; | |
| import 'source-map-support/register’; | |
| export const hello: APIGatewayProxyHandler = async (event) => ({ | |
| statusCode: 200, | |
| body: JSON.stringify({ | |
| message: echo(‘Module aliasing is really the best’), | |
| input: event, | |
| }, null, 2), |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| "scripts": { | |
| "test": "NODE_ENV=test ./node_modules/.bin/jest --ci --verbose", | |
| "lint": "eslint . --ext .js,.jsx,.ts,.tsx", | |
| "buildtest": "tsc --noEmit" | |
| }, |