2020-02-03 10:24:25 +01:00
|
|
|
const Koa = require("koa")
|
2020-04-07 16:12:08 +02:00
|
|
|
const logger = require("koa-logger");
|
2020-02-03 10:24:25 +01:00
|
|
|
const router = require("./middleware/routers")
|
|
|
|
const koaBody = require("koa-body")
|
|
|
|
const initialiseRuntimePackages = require("./initialise/initialiseRuntimePackages")
|
2019-06-14 11:05:46 +02:00
|
|
|
|
2020-02-03 10:24:25 +01:00
|
|
|
const app = new Koa()
|
2019-06-14 11:05:46 +02:00
|
|
|
|
2020-02-03 10:24:25 +01:00
|
|
|
module.exports = async budibaseContext => {
|
|
|
|
const { config } = budibaseContext
|
|
|
|
app.keys = config.keys
|
|
|
|
app.context.master = budibaseContext.master
|
|
|
|
app.context.getAppPackage = await initialiseRuntimePackages(
|
|
|
|
budibaseContext,
|
|
|
|
app.context.master,
|
|
|
|
config.latestPackagesFolder
|
|
|
|
)
|
|
|
|
app.use(koaBody({ multipart: true }))
|
2020-04-07 16:12:08 +02:00
|
|
|
app.use(logger());
|
2020-02-03 10:24:25 +01:00
|
|
|
app.use(router(config, app).routes())
|
|
|
|
return app.listen(config.port)
|
|
|
|
}
|