2020-04-14 16:14:57 +02:00
|
|
|
const send = require("koa-send");
|
|
|
|
const { resolve } = require("path")
|
2020-05-02 16:29:10 +02:00
|
|
|
const { homedir } = require("os");
|
2020-04-14 16:14:57 +02:00
|
|
|
|
|
|
|
// either serve the builder or serve the actual app index.html
|
|
|
|
const builderPath = resolve(process.cwd(), "builder")
|
|
|
|
|
|
|
|
exports.serveBuilder = async function(ctx) {
|
2020-04-28 15:39:35 +02:00
|
|
|
console.log(ctx.file);
|
2020-04-14 16:14:57 +02:00
|
|
|
await send(ctx, ctx.file, { root: builderPath })
|
|
|
|
}
|
|
|
|
|
|
|
|
exports.serveApp = async function(ctx) {
|
|
|
|
// resolve unauthenticated page if so
|
|
|
|
await send(ctx, "/index.html", { root: ctx.publicPath })
|
|
|
|
// resolve main page if user authenticated
|
|
|
|
}
|
|
|
|
|
|
|
|
exports.serveComponentLibrary = async function(ctx) {
|
2020-05-02 16:29:10 +02:00
|
|
|
// TODO: update to run wherever budi is run
|
|
|
|
const componentLibraryPath = resolve(
|
|
|
|
homedir(),
|
|
|
|
".budibase",
|
|
|
|
ctx.params.appId,
|
|
|
|
"node_modules",
|
|
|
|
decodeURI(ctx.query.library),
|
|
|
|
"dist"
|
|
|
|
);
|
|
|
|
|
|
|
|
await send(ctx, "/index.js", { root: componentLibraryPath })
|
|
|
|
}
|
|
|
|
|
|
|
|
exports.serveComponentDefinitions = async function(ctx) {
|
|
|
|
// TODO: update to run wherever budi is run
|
|
|
|
const componentLibraryPath = resolve(
|
|
|
|
homedir(),
|
|
|
|
".budibase",
|
|
|
|
ctx.params.appId,
|
|
|
|
"node_modules",
|
|
|
|
decodeURI(ctx.query.library),
|
|
|
|
"dist"
|
|
|
|
);
|
|
|
|
|
|
|
|
await send(ctx, "/index.js", { root: componentLibraryPath })
|
2020-04-14 16:14:57 +02:00
|
|
|
}
|