Closed Firaenix closed 5 years ago
Thanks for reporting this.
The way I expect to debug this would be to create a new integration test with your code and then see what's going on with debug. If it works locally then I'd move to arduous testing inside an actual Lambda. In this case I'd just write the code as ES6 JS not TS.
I will take a look when I find some time, but one thing I've noticed is the content-type/content-length header sometimes trips up body-parser.
Also since this is basically express, you can see how I have to set these headers:
https://github.com/dougmoscrop/serverless-http/blob/master/test/express.js#L53
I tried to work around the content-length being unset:
https://github.com/dougmoscrop/serverless-http/blob/master/lib/request.js#L33
It's possible this is hitting another scenario that I am missing or that something in an of these libraries has changed, or that something in APIg->Lambda changed :D
Thanks for getting back to me! If there is anything I can do to help, let me know!
I'm really keen on using your library so I'd love to have this working! 👍
Could you put together a minimal, non-TS version? For example, I don't know what is in ./Injector
Sure no worries, working on it now
Here you go, I've mocked up a very quick test server with a controller for you. I've got a readme in there if you need it 😄
I finally got around to peeking at this, sorry it only took over a year :)
I dunno, I wrote this test: https://github.com/dougmoscrop/serverless-http/blob/master/test/inversify.js
and it worked. I didn't obvious set up all the fancy controller/injection stuff. Can you take a look? See if I did something different?
I'm gonna close this out since there's at least a basic test, if anyone wants to PR a failing test I will take it and run with it
Hi,
I was playing around with serverless-http and I love the idea of it! I did however, find an issue when trying to use inversify-express-utils.
Currently, using serverless-http the only way I can send data to my controllers is through using query strings. Even when using body-parser as middleware to express, when passing the body into the XHR that goes through serverless-http, it ends up getting to the controller as an empty object ({}).
If I run my server locally without using my configured lambda.ts, I am able to pass data via body to my controllers.
Any ideas on how to solve this issue?
Thanks very much!
Server.ts: import 'reflect-metadata'; import * as express from 'express'; import { json } from 'body-parser'; import { InversifyExpressServer } from 'inversify-express-utils'; import { InjectModule } from './Injector';
export class Server { public app: express.Application; private _server: InversifyExpressServer;
}
lambda.ts: import { Server } from './Server'; import * as serverless from 'serverless-http';
const server = new Server();
module.exports.handler = serverless(server.app);