Questions tagged [middy]
37 questions
4
votes
2 answers
how to unit test if handler function is called when using middy
im using an http request function as the handler function in middy and then use the ssm middleware to fetch some ssm parameters before initiating the http request.
like this:
const makeThirdPartyServiceRequest = middy(async ({ params }) => {
…

Muhammad Ali Nazar
- 817
- 9
- 18
3
votes
1 answer
Extending a middy middleware function in nodejs
In my lambda code written in nodejs, I want to extend the httpErrorhandler middleware and create a wrapper around it.
Currently I have something like…

Naxi
- 1,504
- 5
- 33
- 72
2
votes
1 answer
middy.js. ERROR: Middleware must be an object containing at least one key among "before", "after", "onError"
I'm trying to get started with Middy to validate input schema on AWS lambda.
The lambda function below keeps throwing this error:
Middleware must be an object containing at least one key among "before", "after", "onError"
Anyone knows what could be…

mvp
- 33
- 4
2
votes
1 answer
TypeError: callback is not a function at terminate (node_modules/middy/src/middy.js:152:16)
My test is failing whenever i used middy, but when i remove it, my test succeed. the error that im encountering is "TypeError: callback is not a function at terminate (C:\cico\node_modules\middy\src\middy.js:152:16)"
I'm stuck and I need…

Poor programmer
- 121
- 12
2
votes
1 answer
Middy, Typescript, and Jest in a monorepo
I've set up a Typescript project using Lerna and yarn workspace. This project includes an AWS API Gateway API that is backed by several Lambda functions that use Middy for things like CORS and handling timeouts. I prefer to have unit tests for my…

Aurelia Peters
- 2,169
- 1
- 20
- 34
2
votes
1 answer
How to apply plugin to @middy/validator?
I'm writing a validation schema for a serverless endpoint using ajv and this @middy/validator middleware. There is a note in documentation that the middleware can use external plugins. But it's not clear how to apply them, and there is no example. I…

Ivan Banha
- 753
- 2
- 12
- 23
1
vote
1 answer
How do I turn off (or increase) timeoutEarlyResponse in Middy?
Debugging a lambda running locally; using lambda-local and starting the handler up then attaching a Chrome debugger. But halfway through debugging I get this…

jcollum
- 43,623
- 55
- 191
- 321
1
vote
1 answer
Jest expect.objectContaining fails even if expected object is part of received
I want to test my middy middleware for my lambda handler using jest. In the middleware I assign a propperty to the request.event which then will be used in the handler.
//hander.ts
const main = async (event: APIGatewayProxyEvent):…

zlZimon
- 2,334
- 4
- 21
- 51
1
vote
2 answers
Fixing Unknown http event format with AWS lambda and middy?
This is a test lambda. Where should the format be specified? Does middy now require event.requestContext.http.method specified somewhere?
import 'source-map-support/register';
import type { ValidatedEventAPIGatewayProxyEvent } from…

Interlated
- 5,108
- 6
- 48
- 79
1
vote
0 answers
Webpack compilation failed: node_modules/@middy/core/index.cjs 24:26
I can't deploy my code to lambda when I use middy; it will always return the error
Error:
Webpack compilation failed:
in D:/web/earthlings/node_modules/@middy/http-json-body-parser/index.cjs 18:59
Module parse failed: Unexpected token (18:59)
…

imin
- 4,504
- 13
- 56
- 103
1
vote
2 answers
What’s the point of exporting something from a JavaScript file when it is not “ready” yet?
Here’s an example: https://middy.js.org/docs/intro/getting-started
import middy from '@middy/core'
import middleware1 from 'sample-middleware1'
import middleware2 from 'sample-middleware2'
import middleware3 from 'sample-middleware3'
const…

Bozi
- 11
- 4
1
vote
1 answer
middy-ssm not picking up changes to the lambda's execution role
We're using middy-ssm to fetch & cache SSM parameter values during lambda initialization. We ran into a situation where the execution role of the lambda did not have access to perform SSM::GetParameters on the path that it attempted to fetch. We…

toman
- 308
- 2
- 6
1
vote
1 answer
My Lambda hangs when accessing LaunchDarkly through a middy wrapper
We're using Middy as a wrapper with all our lambdas to deal with some logging and instrumentation logic, which is great.
We also use LaunchDarkly (launchdarkly-node-server-sdk) to access feature flags serverlessly, following the basic option 1…

Vini Bono
- 85
- 8
1
vote
1 answer
Middy Node js+ Serverless + AWS lambda : How can use single handler for multiple end points?
We have a project in node js with serverless architecture. We are planning to use Middy for AWS lambda function implementation. Our problem is that we do not want to create separate lambda function for each and every api end points, We have very…
1
vote
1 answer
use middy to allow custom headers
I'm using middy for handling middleware for my AWS lambda code. Below is my code:
const middy = require('middy')
const middlewares = require('middy/middlewares')
const handlerWrapper = (handler) => middy((event, context, callback) => {
…

imin
- 4,504
- 13
- 56
- 103