Current Behavior
Sample Code
service: my-service
plugins:
- serverless-offline
provider:
runtime: nodejs12.x
stage: dev
functions:
handler: expressRoutes/indexParcel.hanlder
events:
- http:
path: v1/parcel
method: ANY
integration: lambda
- http:
path: v1/parcel/topic/{proxy+}
method: ANY
integration: lambda
'use strict';
const servers1 = require('serverless-http');
const express = require('express');
const app = express();
app.get('/', function (req, res) {
console.log('110001919292929');
res.setHeader('Content-Type', 'application/json');
res.send('Hello World!')
});
app.get('/:id', function (req, res) {
console.log('111122212121212122');
res.setHeader('Content-Type', 'application/json');
res.send('Hello 123123123!')
});
// module.exports.handler = serverless(app);
//
const handler = servers1(app);
module.exports.handler = async (event, context) => {
// you can do other things here
const result = await handler(event, context);
// and here
return result;
};
Expected behavior/code
Environment
serverless version: [e.g. v1.54.0]serverless-offline version: [e.g. v6.0.0]node.js version: [e.g. v12.14.1]OS: [e.g. macOS 10.13.4, Windows 10, Ubuntu 16.04]_optional, if you are using any of the following frameworks to invoke handlers_
python version: [e.g. v3.8.0]ruby version: [e.g. v2.6.5]Possible Solution
Additional context/Screenshots
after run command sls offline start, and send http request, the terminal reports error "offline: handler 'hanlder' in expressRoutes/indexParcel is not a function
", I try slove this problem, but it's not helpful, anyone has idea for this problem, thank you very much, thank you.
@Dong9769 You have a typo on your serverless.yml file:
handler: expressRoutes/indexParcel.hanlder`
It should be:
handler: expressRoutes/indexParcel.handler
@KingDarBoja Thank you, I was so careless. when the problem occurs in terminal, at first, I checked the spelling, I didn't find this problem. Thank you very much.
You're welcome. Please close the issue as this wasn't a bug with the package itself 馃嵃
Most helpful comment
@KingDarBoja Thank you, I was so careless. when the problem occurs in terminal, at first, I checked the spelling, I didn't find this problem. Thank you very much.