budibase/packages/server/app.js

21 lines
664 B
JavaScript
Raw Normal View History

2019-06-14 11:05:46 +02:00
const Koa = require('koa');
const app = new Koa();
const getMasterAppInternal = require("./utilities/masterAppInternal");
const router = require("./middleware/routers");
const bodyParser = require('koa-bodyparser');
2019-06-25 23:48:22 +02:00
const initialiseRuntimeApps = require("./initialise/initialiseRuntimePackages");
2019-06-14 11:05:46 +02:00
module.exports = async (config) => {
app.keys = config.keys;
app.context.master = await getMasterAppInternal(config);
2019-06-25 23:48:22 +02:00
app.context.getAppPackage = await initialiseRuntimeApps(
config,
app.context.master,
config.latestAppsPath
)
2019-06-14 11:05:46 +02:00
app.use(bodyParser());
2019-06-14 18:01:01 +02:00
app.use(router(config, app).routes());
2019-06-14 11:05:46 +02:00
return app.listen();
};