probot / adapter-aws-lambda-serverless

An extension for running Probot on Lambda
ISC License
94 stars 36 forks source link

async start #37

Closed figadore closed 4 years ago

figadore commented 4 years ago

I've spend a few hours on this, and hoping there's an easy answer that I'm just missing somehow. Is there a way to wait to start listening for webhook events until some async things have happened, such as getting secrets from paramstore and setting them as envs?

figadore commented 4 years ago

I think I finally got it

module.exports.probot = (event, context) => new Promise(async (resolve, reject) => {
    try {
      const result = await setEnvs();
    } catch (e) {
      console.error("Unable to set required environment variables");
      return reject(e);
    }
    const handler = serverless(appFn);
    return resolve(handler(event, context));
  }
);

Closing, but suggestions still welcome