2020-05-07 11:53:34 +02:00
|
|
|
const Router = require("@koa/router")
|
|
|
|
const controller = require("../controllers/static")
|
2020-04-14 16:14:57 +02:00
|
|
|
|
2020-05-07 11:53:34 +02:00
|
|
|
const router = Router()
|
2020-04-14 16:14:57 +02:00
|
|
|
|
|
|
|
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()
|
2020-04-14 16:14:57 +02:00
|
|
|
})
|
|
|
|
.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-04-14 16:14:57 +02:00
|
|
|
|
2020-05-07 11:53:34 +02:00
|
|
|
module.exports = router
|