2020-02-03 10:24:25 +01:00
|
|
|
const Koa = require("koa")
|
2020-04-03 18:35:20 +02:00
|
|
|
const router = require("./middleware/routes/builderRouter")
|
2020-02-03 10:24:25 +01:00
|
|
|
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 }))
|
|
|
|
app.use(router(config, app).routes())
|
|
|
|
return app.listen(config.port)
|
|
|
|
}
|