budibase/packages/server/app.js

21 lines
673 B
JavaScript
Raw Normal View History

const Koa = require("koa");
2019-06-14 11:05:46 +02:00
const router = require("./middleware/routers");
const koaBody = require("koa-body");
2019-06-28 23:59:27 +02:00
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) => {
2019-07-09 08:29:50 +02:00
const { config } = budibaseContext;
2019-06-14 11:05:46 +02:00
app.keys = config.keys;
2019-07-09 08:29:50 +02:00
app.context.master = budibaseContext.master;
2019-06-28 23:59:27 +02:00
app.context.getAppPackage = await initialiseRuntimePackages(
2019-07-09 08:29:50 +02:00
budibaseContext,
2019-06-25 23:48:22 +02:00
app.context.master,
2019-07-13 11:35:57 +02:00
config.latestPackagesFolder
2019-07-09 08:29:50 +02:00
);
2020-01-29 22:04:48 +01:00
app.use(koaBody({ multipart: true }));
2019-06-14 18:01:01 +02:00
app.use(router(config, app).routes());
return app.listen(config.port);
2019-06-14 11:05:46 +02:00
};