budibase/packages/server/app.js

21 lines
642 B
JavaScript
Raw Normal View History

const Koa = require("koa")
2020-04-03 18:35:20 +02:00
const router = require("./middleware/routes/builderRouter")
const koaBody = require("koa-body")
const initialiseRuntimePackages = require("./initialise/initialiseRuntimePackages")
2019-06-14 11:05:46 +02:00
const app = new Koa()
2019-06-14 11:05:46 +02: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)
}