budibase/packages/server/api/routes/static.js

22 lines
616 B
JavaScript
Raw Normal View History

2020-05-07 11:53:34 +02:00
const Router = require("@koa/router")
const controller = require("../controllers/static")
2020-05-07 11:53:34 +02:00
const router = Router()
router
.param("file", async (file, ctx, next) => {
2020-05-07 11:53:34 +02:00
ctx.file = file && file.includes(".") ? file : "index.html"
2020-05-06 13:17:15 +02:00
2020-05-06 21:29:47 +02:00
// Serving the client library from your local dir in dev
2020-05-06 13:17:15 +02:00
if (ctx.isDev && ctx.file.startsWith("budibase-client")) {
2020-05-07 11:53:34 +02:00
ctx.devPath = "/tmp/.budibase"
2020-05-06 13:17:15 +02:00
}
2020-05-07 11:53:34 +02:00
await next()
})
.get("/_builder/:file*", controller.serveBuilder)
2020-05-04 18:13:57 +02:00
.get("/:appId/componentlibrary", controller.serveComponentLibrary)
2020-05-07 11:53:34 +02:00
.get("/:appId/:file*", controller.serveApp)
2020-05-07 11:53:34 +02:00
module.exports = router