budibase/packages/server/app.js

21 lines
674 B
JavaScript
Raw Normal View History

2019-06-14 11:05:46 +02:00
const Koa = require('koa');
const app = new Koa();
const router = require("./middleware/routers");
2019-06-28 23:59:27 +02:00
const koaBody = require('koa-body');
const initialiseRuntimePackages = require("./initialise/initialiseRuntimePackages");
2019-06-14 11:05:46 +02:00
2019-07-09 08:29:50 +02:00
module.exports = async (budibaseContext) => {
2019-06-14 11:05:46 +02:00
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
);
2019-06-28 23:59:27 +02:00
app.use(koaBody({ multipart : true }));
2019-06-14 18:01:01 +02:00
app.use(router(config, app).routes());
2019-07-13 11:35:57 +02:00
return app.listen(config.port);
2019-06-14 11:05:46 +02:00
};