You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
import{APIGatewayProxyEvent,APIGatewayProxyResult}from'aws-lambda';importmiddyfrom'@middy/core';importvalidatorfrom'@middy/validator';import{transpileSchema}from'@middy/validator/transpile';importhttpHeaderNormalizerfrom'@middy/http-header-normalizer';importhttpJsonBodyParserfrom'@middy/http-json-body-parser';import{getPackageVersion,getProgramsS3BucketName}from'../helpers/env';import{uploadFileToS3}from'../lib/s3';typePostProgramEvent=APIGatewayProxyEvent&{body: {content: string;filePath: string;};};consteventSchema={type: 'object',required: ['body'],properties: {body: {type: 'object',required: ['content','filePath'],properties: {content: {type: 'string',},filePath: {type: 'string',},},},},};constresponseSchema={type: 'object',required: ['body','statusCode'],properties: {body: {type: 'string',},statusCode: {type: 'number',},},};// TODO: Get rid of the explicit partial type middy.MiddyfiedHandler// and use the implicit type instead.consthandler: middy.MiddyfiedHandler=middy<PostProgramEvent,APIGatewayProxyResult>().use(httpHeaderNormalizer()).use(httpJsonBodyParser()).use(validator({eventSchema: transpileSchema(eventSchema),responseSchema: transpileSchema(responseSchema),}),).handler(async(event)=>{const{ content, filePath }=event.body;console.log(`Received program ${filePath} with content: ${content}`);constprogramsS3BucketName=getProgramsS3BucketName();if(!programsS3BucketName)thrownewError('Programs S3 Bucket Name is not defined.');constpackageVersion=getPackageVersion();if(!packageVersion)thrownewError('Package Version is not defined.');console.log(`Uploading to s3://${programsS3BucketName}/${filePath}...`);awaituploadFileToS3({bucketName: programsS3BucketName,
filePath,fileContent: Buffer.from(event.body.content,'utf8'),});return{statusCode: 200,body: JSON.stringify({message: 'Program uploaded successfully to S3.',}),};});export{handler};
The text was updated successfully, but these errors were encountered:
and use the implicit type instead.
https://api.github.com/nanlabs/devops-reference/blob/41f65c1c2a3173b66a37e22ebfb443074574bdf8/examples/serverless-localstack-with-s3-and-dynamodb/src/rest/program.ts#L49
The text was updated successfully, but these errors were encountered: