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 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 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
| 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 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
| 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 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 @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 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
| function getNoteTypes(locale = "uk") { | |
| const types = { | |
| uk: [ | |
| { | |
| noteTypeId: 1, | |
| type: "Draft", | |
| }, | |
| { | |
| noteTypeId: 2, | |
| type: "Published", |
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": "2017-02-28", | |
| "payload": ${noteTypes} | |
| } |
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 no-undef */ | |
| const { getNoteTypes } = require("./src/note-types/get-note-types"); | |
| const { getErrorTypes } = require("./src/error-types/get-error-types"); | |
| const { getErrorMessages } = require("./src/error-messages/get-error-messages"); | |
| const serverlessConfiguration = { | |
| service: "serverless-appsync-i18n", | |
| frameworkVersion: "2", | |
| plugins: ["serverless-appsync-plugin"], | |
| provider: { |
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
| #if($ctx.args.noteId == 0) | |
| $utils.error($util.str.toReplace("${invalidValueErrorMessage}", "{0}", "$ctx.args.noteId"), "${invalidValueErrorType}") | |
| #else | |
| { | |
| "version" : "2017-02-28", | |
| "operation" : "GetItem", | |
| "key" : { | |
| "noteId" : { "S" : "${context.arguments.noteId}" }, | |
| }, | |
| "consistentRead" : true |
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
| function getErrorTypes(locale = "uk") { | |
| const errorTypes = { | |
| uk: { | |
| noDataErrorType: "NoData", | |
| accessDeniedErrorType: "AccessDenied", | |
| invalidValueErrorType: "InvalidValue", | |
| }, | |
| fr: { | |
| noDataErrorType: "PasDeDonnées", | |
| accessDeniedErrorType: "AccèsRefusé", |
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
| function getErrorMessages(locale = "uk") { | |
| const errorMessages = { | |
| uk: { | |
| noDataErrorMessage: "No data", | |
| accessDeniedErrorMessage: "Access denied", | |
| invalidValueErrorMessage: "The value {0} is invalid", | |
| }, | |
| fr: { | |
| noDataErrorMessage: "Pas de données", | |
| accessDeniedErrorMessage: "Accès refusé", |