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: 2 | |
| updates: | |
| # Maintain dependencies for GitHub Actions | |
| - package-ecosystem: "github-actions" | |
| directory: "/" | |
| schedule: | |
| interval: "daily" | |
| # Maintain dependencies for npm | |
| - package-ecosystem: "npm" | |
| directory: "/" |
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
| documentation: | |
| version: '1' | |
| title: ${self:custom.openapiTitle} | |
| description: ${self:custom.openapiTitle} - example OpenAPI document | |
| endpoints: | |
| getImage: | |
| summary: "Get Image by ID" | |
| description: "Get a pre-signed temporary download URL for the image by ID" | |
| requestBody: | |
| description: "Get a pre-signed temporary download URL for the image by 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
| import AWS from 'aws-sdk'; | |
| import { APIGatewayProxyHandler, APIGatewayProxyResult, APIGatewayEvent } from 'aws-lambda'; | |
| import { v4 as uuid } from 'uuid'; | |
| import { schema } from './add-comment.schema'; | |
| import { validate } from '../../shared/validator'; | |
| const METHOD = 'add-comment.handler'; | |
| const LANGUAGE_CODE = 'en'; | |
| type DetectPiiEntitiesResponse = AWS.Comprehend.DetectPiiEntitiesResponse; |
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 AWS from 'aws-sdk'; | |
| import { APIGatewayProxyHandler, APIGatewayProxyResult, APIGatewayEvent } from 'aws-lambda'; | |
| import { v4 as uuid } from 'uuid'; | |
| import config from '../../config'; | |
| const METHOD = 'upload-file.handler'; | |
| const s3 = new AWS.S3(); | |
| export const handler: APIGatewayProxyHandler = async ({ |
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 AWS from 'aws-sdk'; | |
| import { APIGatewayProxyHandler, APIGatewayProxyResult, APIGatewayEvent } from 'aws-lambda'; | |
| import { v4 as uuid } from 'uuid'; | |
| import config from '../../config'; | |
| type HeadObjectRequest = AWS.S3.HeadObjectRequest; | |
| type HeadObjectOutput = AWS.S3.HeadObjectOutput; | |
| const METHOD = 'get-file.handler'; |
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, APIGatewayProxyResult } from 'aws-lambda'; | |
| import { getFilesFromFolder } from '../shared/get-files-from-folder/get-files-from-folder'; | |
| 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 efs folder ${config.efsMountPath}`); |
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, 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}`); |
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, 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 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
| export const schema = { | |
| type: "object", | |
| required: ["id", "firstName", "surname", "age"], | |
| maxProperties: 4, | |
| minProperties: 4, | |
| properties: { | |
| id: { | |
| type: "number", | |
| }, | |
| firstName: { |
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
| // 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) { |