This file contains 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": "2017-02-28", | |
"payload": ${noteTypes} | |
} |
This file contains 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
function getNoteTypes(locale = "uk") { | |
const types = { | |
uk: [ | |
{ | |
noteTypeId: 1, | |
type: "Draft", | |
}, | |
{ | |
noteTypeId: 2, | |
type: "Published", |
This file contains 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 @typescript-eslint/no-var-requires */ | |
import AWS from 'aws-sdk'; | |
import { v4 as uuid } from 'uuid'; | |
import { APIGatewayProxyHandler, APIGatewayEvent, APIGatewayProxyResult } from 'aws-lambda'; | |
import { config } from './shared/config'; | |
import { Browser, Page } from 'puppeteer-core'; | |
const chromium = require('chrome-aws-lambda'); | |
let browser: Browser; | |
let page: Page; |
This file contains 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
config: | |
plugins: | |
expect: {} # this plugin allows for assertions: https://artillery.io/docs/guides/plugins/plugin-expectations-assertions.html | |
ensure: | |
p95: 1000 # ensure latency is equal to or under 1000ms | |
maxErrorRate: 0 # no percentage of error rate i.e. no errors or pipeline fails | |
payload: | |
path: "./data/data.csv" # pull in the employee data csv | |
fields: | |
- "id" |
This file contains 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
config: | |
plugins: | |
expect: {} # this plugin allows for assertions: https://artillery.io/docs/guides/plugins/plugin-expectations-assertions.html | |
fuzzer: {} # this plugin allows for fuzzing: https://artillery.io/docs/guides/plugins/plugin-fuzzer.html | |
ensure: | |
maxErrorRate: 0 # no percentage of error rate i.e. no errors or pipeline fails | |
payload: | |
path: "./data/data.csv" # pull in the employee data csv | |
fields: | |
- "id" |
This file contains 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 Ajv from "ajv"; | |
import { AppError } from "../errors/app-error"; | |
import { errorTypes, logLevels } from "../errors/error-constants"; | |
export function validate(obj, schema) { | |
const ajv = new Ajv({ | |
allErrors: true, | |
}); | |
const validator = ajv.compile(schema); |
This file contains 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
// basic error handler which will not expose any stack traces/secrets | |
// and will return the correct responses when invalid params from validator | |
export const errorHandler = (error) => { | |
let body = "An error has occurred"; | |
let statusCode = 500; | |
const errorType = error && error.errorType ? error.errorType : 2; | |
switch (errorType) { |
This file contains 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
export const schema = { | |
type: "object", | |
required: ["id", "firstName", "surname", "age"], | |
maxProperties: 4, | |
minProperties: 4, | |
properties: { | |
id: { | |
type: "number", | |
}, | |
firstName: { |
This file contains 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, APIGatewayProxyResult } from 'aws-lambda'; | |
import { getImagesFromBucket } from '../shared/get-images-from-bucket/get-images-from-bucket'; | |
import { getFilesFromFolder } from '../shared/get-files-from-folder/get-files-from-folder'; | |
import { writeFilesToFolder } from '../shared/write-files-to-folder/write-files-to-folder'; | |
import { sortFiles } from '../shared/sort-files/sort-files'; | |
import FileObject from '../shared/types/FileObject'; | |
import { config } from '../shared/config/config'; | |
async function getFiles(): Promise<FileObject[]> { | |
// attempt to get the files from /tmp on the lambda |
This file contains 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, APIGatewayProxyResult } from 'aws-lambda'; | |
import { getImagesFromBucket } from '../shared/get-images-from-bucket/get-images-from-bucket'; | |
import { sortFiles } from '../shared/sort-files/sort-files'; | |
import { config } from '../shared/config/config'; | |
import FileObject from '../shared/types/FileObject'; | |
export const handler: APIGatewayProxyHandler = async (): Promise<APIGatewayProxyResult> => { | |
try { | |
console.log(`Get the files from the s3 bucket ${config.bucketName}`); |