The function where you would initialise your koa app can be an async function. In my project what I do is I create my koa app and call the above two lines in an async function, then on start up I call that async function and only start the server inside the then. So something like this:
asyncfunctionsetup(){constapp=newKoa();constenforcer=awaitnewEnforcer('path/to/model.conf','path/to/policy.csv');app.use(authorisation(enforcer));//...all other setupreturnapp;}
and then on start up of the service I would do something like this:
The function where you would initialise your koa app can be an async function. In my project what I do is I create my koa app and call the above two lines in an async function, then on start up I call that async function and only start the server inside the
then
. So something like this:and then on start up of the service I would do something like this: