2019-06-14 21:05:46 +12:00
|
|
|
const Koa = require('koa');
|
|
|
|
const app = new Koa();
|
|
|
|
const router = require("./middleware/routers");
|
2019-06-29 09:59:27 +12:00
|
|
|
const koaBody = require('koa-body');
|
|
|
|
const initialiseRuntimePackages = require("./initialise/initialiseRuntimePackages");
|
2019-06-14 21:05:46 +12:00
|
|
|
|
2019-07-09 18:29:50 +12:00
|
|
|
module.exports = async (budibaseContext) => {
|
2019-06-14 21:05:46 +12:00
|
|
|
|
2019-07-09 18:29:50 +12:00
|
|
|
const { config } = budibaseContext;
|
2019-06-14 21:05:46 +12:00
|
|
|
app.keys = config.keys;
|
2019-07-09 18:29:50 +12:00
|
|
|
app.context.master = budibaseContext.master;
|
2019-06-29 09:59:27 +12:00
|
|
|
app.context.getAppPackage = await initialiseRuntimePackages(
|
2019-07-09 18:29:50 +12:00
|
|
|
budibaseContext,
|
2019-06-26 09:48:22 +12:00
|
|
|
app.context.master,
|
2019-07-13 21:35:57 +12:00
|
|
|
config.latestPackagesFolder
|
2019-07-09 18:29:50 +12:00
|
|
|
);
|
2019-06-29 09:59:27 +12:00
|
|
|
app.use(koaBody({ multipart : true }));
|
2019-06-15 04:01:01 +12:00
|
|
|
app.use(router(config, app).routes());
|
2019-07-13 21:35:57 +12:00
|
|
|
return app.listen(config.port);
|
2019-06-14 21:05:46 +12:00
|
|
|
};
|