Skip to content

Don't create server if it was already created earlier. #81

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from

Conversation

lynx-r
Copy link

@lynx-r lynx-r commented May 30, 2017

Hello,

I'd like to suggest the pull request. It is about not creating http server if it was already created. I faced with this problem when I tried to use Restify with this library.

@brettstack
Copy link
Collaborator

Do you have a Restify+aws-serverless-express example you can share? Are you calling createServer outside the handler?

@lynx-r
Copy link
Author

lynx-r commented May 30, 2017

There is an example of how I applied it:

export class ServerLambda extends ServerBase {
  private server: Server;

  bootstrap() {
    super.bootstrap();
    //create restify application
    this.app = new InversifyRestifyServer(container, {
      name: AppConstants.APP_NAME,
      version: nconf.get("server:api_version"),
      log: this.logger
    }).setConfig((app) => {
      this.config(app);
      this.configLambda(app);
    }).build();
    // this.configLambda(this.app);
  }

  private configLambda(app) {
    app.use(awsServerlessExpressMiddleware.eventContext());
    this.server = awsServerlessExpress.createServer(app, null, AppConstants.BINARY_MIME_TYPES);
  }

  handler(event, context) {
    awsServerlessExpress.proxy(this.server, event, context);
  }

}

My repository: https://github.com/lynx-r/-my-aws-lambda-example/blob/master/src/server-lambda.ts

@brettstack brettstack closed this Apr 10, 2018
@lynx-r lynx-r deleted the createServer_object branch April 10, 2018 19:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants