Which version of the plugin serverless-middleware supports function level middleware and whats the syntax
Closed this issue · 1 comments
I am trying to implement middleware at function level by following this doc.
But the middleware function I have written in a separate file and referenced in the serverless.yml is not even getting deployed (I checked by downloading the lambda function) i.e. middleware at function level not even getting registered.
Any idea where I am missing something?
Note: the middleware at package level is working perfectly but I have a requirement to implement it at function level.
Node version used: 14
"serverless": "^2.66.0",
"serverless-domain-manager": "^5.1.0",
"serverless-dotenv-plugin": "^3.10.0",
"serverless-middleware": "^0.0.15",
"serverless-offline": "^8.5.0",
"serverless-openapi-documentation-v2": "^0.4.6",
"serverless-plugin-typescript": "2.1.0",
"serverless-prune-plugin": "^1.6.1",
Below is the sample code of the serveless file:
provider:
name: aws
runtime: nodejs14.x
functions:
my-function:
middleware:
pre:
- src/authMiddleware.authenticate
post:
- catch: src/catchHandler.catchErrors
handler: src/handler.users
timeout: 30
events:
-service: your-service-name
plugins:
- serverless-dotenv-plugin
- serverless-offline
- serverless-middleware
- serverless-domain-manager
- serverless-plugin-typescript
- serverless-openapi-documentation-v2
- serverless-prune-plugin
custom:
middleware:
pre:
- src/initialMiddleware.init
pos:
- catch: src/catchHandler.catchErrors
Hi,
You are usign version 0.15 of the middleware package whereas the latest version is 3.1.0.
You should upgrade as there were breaking changes on the major version releases.