Questions tagged [middy]

37 questions
0
votes
1 answer

How to test a handler function which is wrapped in middy?

I want to test my handler which is wrapped in middleware using middy like this: const main = async (event: APIGatewayProxyEvent): Promise => { // .... // }; export const handle = middy(main) .use(httpJsonBodyParser()) …
zlZimon
  • 2,334
  • 4
  • 21
  • 51
0
votes
1 answer

Middy onError not called

I'm using lambda powertools and middy for cross-cutting concerns. I have a simple error middleware export const errorLogger = ({ logger }: { logger: Logger }): middy.MiddlewareObj => { const onError = async (request: middy.Request) => { …
florian norbert bepunkt
  • 2,099
  • 1
  • 21
  • 32
0
votes
0 answers

Can not satisfy the type for generic middy middleware

I want to have a custom middy middleware which parses the event.body with zod and saves it already typed to the request so that it can be used in the handler. This is what I have so far: export interface TypedAPIGatewayProxyEvent
zlZimon
  • 2,334
  • 4
  • 21
  • 51
0
votes
0 answers

Unable to read the value from ssm using middy in nodejs

Can someone help me with below code issue, For some reason. Lambda is giving me error Log: { "errorType": "TypeError", "errorMessage": "Cannot read properties of undefined (reading 'Parameter')", "stack": [ "TypeError: Cannot read properties of…
Abhinay
  • 153
  • 4
  • 25
0
votes
1 answer

endless dead letter queue (DLQ) processing when Middy.js SQS queue validator fails

I've got a lambda handler that processes incoming SQS events. There is a middyJs handler with a validator middleware on top of that. When MiddyJs validation fails the event gets stuck in an endless loop inside DLQ. When I throw an Error…
Pouyan
  • 15
  • 5
0
votes
1 answer

SyntaxError when using middleware with middy - but there is no syntax error- and custom middleware works

I have a simple lambda (behind a cognito authorizer) with an http event. I am using the httpJsonParser to parse the body, then I am using a custom middleware which just validates the json using zod and last but not least I am using the…
zlZimon
  • 2,334
  • 4
  • 21
  • 51
0
votes
0 answers

Why does the headers option not work for setting Access-Control-Allow-Headers using Middy and Serverless?

I am getting the following error when trying to do a POST against my Serverless API that uses AWS API Gateway: Access to fetch at 'https://example.com/shop' from origin 'https://otherexample.com' has been blocked by CORS policy: Request header…
Chad Johnson
  • 21,215
  • 34
  • 109
  • 207
0
votes
1 answer

Can I validate the length of something by middy?

const baseHandler: APIGatewayProxyHandlerV2 = async (event) => { return service.create(event.body); } const inputSchema = { type: "object", properties: { body: { type: "object", properties: { year: { type: "number" }, …
0
votes
0 answers

How to add gates to Objection in NodeJS (AWS Lambda)?

I have an API developed with Serverless and serverless-offline which is deployed to AWS Lambda. Objection/Knex is used for DB, Firebase for authentication, and Middy to manage the requests. For the logged-in users, I'm trying to: Automatically add…
Mahesh Samudra
  • 1,039
  • 1
  • 11
  • 25
0
votes
0 answers

how to create safe custom middleware using middy

I want to create a safe custom middleware, what ever happens inside this middleware should NOT stop the flow. middleware code: export const customMiddleWare = (options = {}) => { const before = async (request) => { // request.event is…
Ahmad Ali
  • 704
  • 1
  • 10
  • 28
0
votes
0 answers

Improve Http validation error message in middy validator of lambda

When I develop sample apps by serverless-framework, I use middy validator,I expect that when validation error occured, detailed information will be returned. const transactions: ValidatedEventAPIGatewayProxyEvent = async (event) => {…
Heisenberg
  • 4,787
  • 9
  • 47
  • 76
0
votes
0 answers

Getting path parameters from an event in API Gateway Lambda proxy integration

I've a simple Lambda proxy integration. Here's my stack: const lambda = new NodejsFunction(this, "SomeLambda", { entry: path.join(__dirname, "..", "src", "index.ts"), handler: "handler", }); new LambdaRestApi(this,…
0
votes
1 answer

How can I use the Middy validator to validate pathParameters and queryStringParameters?

I created a brand new project using the TypeScript template: $ serverless create --template aws-nodejs-typescript --path demo I edited tsconfig.json and enabled strictNullChecks as I prefer this feature to be turned on: { "extends":…
Bozi
  • 11
  • 4
0
votes
1 answer

What is the excution order when using the middy warmup middleware?

So i'm currently using the middy warmup middleware and had a .before() at the end. I'm just wondering what the order of execution is? does it go straight to the .before block or does it check if its warmed up first? I'm new to all this so sorry if…
Yousuf
  • 61
  • 5
0
votes
1 answer

NodeJs, AWS, From a lambda how to read a file contents of S3 bucket, using AWS SDK V3

Using the AWS SDK version 3, how to read a file of S3 bucket from a nodejs based lambda? I'm creating this for my self reference in the future. I use middy middleware in my lambdas. Hence, used the same template. Please note that it's…
FullMoon
  • 724
  • 6
  • 20