1
0
Fork 0
mirror of synced 2024-07-04 05:50:57 +12:00
This commit is contained in:
Martin McKeaveney 2020-04-06 14:16:21 +01:00
parent fea50bb56e
commit c37cff7712
6 changed files with 24872 additions and 32173 deletions

View file

@ -1,5 +1,5 @@
const Koa = require("koa")
const router = require("./middleware/routes/builderRouter")
const router = require("./middleware/routers")
const koaBody = require("koa-body")
const initialiseRuntimePackages = require("./initialise/initialiseRuntimePackages")

View file

@ -0,0 +1,7 @@
{
"name": "newscreen",
"props": {
"_component": "@budibase/standard-component/div",
"className": "something else"
}
}

File diff suppressed because one or more lines are too long

View file

@ -1,2 +1,2 @@
window['##BUDIBASE_FRONTEND_DEFINITION##'] = {"componentLibraries":[{"importPath":"/lib/customComponents/index.js","libName":"./customComponents"},{"importPath":"/lib/moreCustomComponents/index.js","libName":"./moreCustomComponents"}],"appRootPath":"","page":{"title":"Test App","favicon":"./_shared/favicon.png","stylesheets":["my-styles.css"],"componentLibraries":["./customComponents","./moreCustomComponents"],"props":{"_component":"@budibase/standard-components/container","type":"div"}},"screens":[{"name":"screen1","description":"","props":{"_component":"@budibase/standard-components/container","className":"","type":"div"},"_css":"/css/d121e1ecc6cf44f433213222e9ff5d40.css"},{"name":"screen2","description":"","props":{"_component":"@budibase/standard-components/container","className":"","type":"div"},"_css":"/css/7b7c05b78e05c06eb8d69475caadfea3.css"}]};
window['##BUDIBASE_FRONTEND_DEFINITION##'] = {"componentLibraries":[{"importPath":"/lib/node_modules/@budibase/standard-components/dist/index.js","libName":"@budibase/standard-components"},{"importPath":"/lib/customComponents/index.js","libName":"./customComponents"},{"importPath":"/lib/moreCustomComponents/index.js","libName":"./moreCustomComponents"}],"appRootPath":"","page":{"title":"Test App","favicon":"./_shared/favicon.png","stylesheets":["my-styles.css"],"componentLibraries":["@budibase/standard-components","./customComponents","./moreCustomComponents"],"props":{"_component":"@budibase/standard-components/container","type":"div"}},"screens":[{"name":"screen1","description":"","props":{"_component":"@budibase/standard-components/container","className":"","type":"div"},"_css":"/css/d121e1ecc6cf44f433213222e9ff5d40.css"},{"name":"screen2","description":"","props":{"_component":"@budibase/standard-components/container","className":"","type":"div"},"_css":"/css/7b7c05b78e05c06eb8d69475caadfea3.css"}]};
window['##BUDIBASE_FRONTEND_FUNCTIONS##'] = {'1234':() => 'test return'}

View file

@ -6,14 +6,14 @@ const send = require("koa-send")
const routeHandlers = require("./routeHandlers")
const {
componentLibraryInfo,
} = require("../../utilities/builder")
} = require("../utilities/builder")
const {
componentRoutes,
appsRoutes,
pageRoutes,
userRoutes,
authenticatedRoutes
} = require("./");
} = require("./routes");
const builderPath = resolve(__dirname, "../../builder")
@ -86,30 +86,32 @@ module.exports = (config, app) => {
await next()
}
})
.get("/_builder", async ctx => {
await send(ctx, "/index.html", { root: builderPath })
})
.get("/_builder/:appname/componentlibrary", async ctx => {
const info = await componentLibraryInfo(
ctx.config,
ctx.params.appname,
ctx.query.lib
)
await send(ctx, info.components._lib || "index.js", { root: info.libDir })
})
.get("/_builder/*", async (ctx, next) => {
const path = ctx.path.replace("/_builder", "")
const isFile = new RegExp(/(.+\..{1,5})/g).test(path)
if (path.startsWith("/api/") || path.startsWith("/instance/")) {
await next()
} else if (isFile) {
await send(ctx, path, { root: builderPath })
} else {
router
.get("/_builder", async ctx => {
await send(ctx, "/index.html", { root: builderPath })
}
})
})
.get("/_builder/:appname/componentlibrary", async ctx => {
const info = await componentLibraryInfo(
ctx.config,
ctx.params.appname,
ctx.query.lib
)
await send(ctx, info.components._lib || "index.js", { root: info.libDir })
})
.get("/_builder/*", async (ctx, next) => {
const path = ctx.path.replace("/_builder", "")
const isFile = new RegExp(/(.+\..{1,5})/g).test(path)
if (path.startsWith("/api/") || path.startsWith("/instance/")) {
await next()
} else if (isFile) {
await send(ctx, path, { root: builderPath })
} else {
await send(ctx, "/index.html", { root: builderPath })
}
})
router.use(userRoutes.routes());
router.use(userRoutes.allowedMethods());