Merge branch 'master' of github.com:Budibase/budibase into feature/routify
This commit is contained in:
commit
5b2b4a9aa1
File diff suppressed because it is too large
Load Diff
File diff suppressed because one or more lines are too long
|
@ -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'}
|
window['##BUDIBASE_FRONTEND_FUNCTIONS##'] = {'1234':() => 'test return'}
|
|
@ -4,19 +4,16 @@ const StatusCodes = require("../utilities/statusCodes")
|
||||||
const { resolve } = require("path")
|
const { resolve } = require("path")
|
||||||
const send = require("koa-send")
|
const send = require("koa-send")
|
||||||
const routeHandlers = require("./routeHandlers")
|
const routeHandlers = require("./routeHandlers")
|
||||||
|
|
||||||
const {
|
const {
|
||||||
getPackageForBuilder,
|
|
||||||
getComponentDefinitions,
|
|
||||||
getApps,
|
|
||||||
saveScreen,
|
|
||||||
renameScreen,
|
|
||||||
deleteScreen,
|
|
||||||
buildPage,
|
|
||||||
componentLibraryInfo,
|
componentLibraryInfo,
|
||||||
listScreens,
|
|
||||||
saveBackend,
|
|
||||||
} = require("../utilities/builder")
|
} = require("../utilities/builder")
|
||||||
|
const {
|
||||||
|
componentRoutes,
|
||||||
|
appsRoutes,
|
||||||
|
pageRoutes,
|
||||||
|
userRoutes,
|
||||||
|
authenticatedRoutes
|
||||||
|
} = require("./routes");
|
||||||
|
|
||||||
const builderPath = resolve(__dirname, "../builder")
|
const builderPath = resolve(__dirname, "../builder")
|
||||||
|
|
||||||
|
@ -28,6 +25,7 @@ module.exports = (config, app) => {
|
||||||
.use(async (ctx, next) => {
|
.use(async (ctx, next) => {
|
||||||
ctx.sessionId = ctx.session._sessCtx.externalKey
|
ctx.sessionId = ctx.session._sessCtx.externalKey
|
||||||
ctx.session.accessed = true
|
ctx.session.accessed = true
|
||||||
|
ctx.config = config
|
||||||
|
|
||||||
const pathParts = ctx.path.split("/")
|
const pathParts = ctx.path.split("/")
|
||||||
|
|
||||||
|
@ -45,6 +43,7 @@ module.exports = (config, app) => {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Builder URLs should have admin access to the API
|
||||||
if (ctx.path.startsWith("/_builder/instance/_master")) {
|
if (ctx.path.startsWith("/_builder/instance/_master")) {
|
||||||
const {
|
const {
|
||||||
instance,
|
instance,
|
||||||
|
@ -87,244 +86,51 @@ module.exports = (config, app) => {
|
||||||
await next()
|
await next()
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.get("/_builder", async ctx => {
|
|
||||||
await send(ctx, "/index.html", { root: builderPath })
|
|
||||||
})
|
|
||||||
.get("/_builder/:appname/componentlibrary", async ctx => {
|
|
||||||
const info = await componentLibraryInfo(
|
|
||||||
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)
|
router
|
||||||
|
.get("/_builder", async ctx => {
|
||||||
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 })
|
await send(ctx, "/index.html", { root: builderPath })
|
||||||
}
|
})
|
||||||
})
|
.get("/_builder/:appname/componentlibrary", async ctx => {
|
||||||
.post("/:appname/api/authenticate", routeHandlers.authenticate)
|
const info = await componentLibraryInfo(
|
||||||
.post(
|
ctx.config,
|
||||||
"/_builder/instance/:appname/:instanceid/api/authenticate",
|
|
||||||
routeHandlers.authenticate
|
|
||||||
)
|
|
||||||
.post(
|
|
||||||
"/:appname/api/setPasswordFromTemporaryCode",
|
|
||||||
routeHandlers.setPasswordFromTemporaryCode
|
|
||||||
)
|
|
||||||
.post(
|
|
||||||
"/_builder/instance/:appname/:instanceid/api/setPasswordFromTemporaryCode",
|
|
||||||
routeHandlers.setPasswordFromTemporaryCode
|
|
||||||
)
|
|
||||||
.post(
|
|
||||||
"/:appname/api/createTemporaryAccess",
|
|
||||||
routeHandlers.createTemporaryAccess
|
|
||||||
)
|
|
||||||
.post(
|
|
||||||
"/_builder/instance/:appname/:instanceid/api/createTemporaryAccess",
|
|
||||||
routeHandlers.createTemporaryAccess
|
|
||||||
)
|
|
||||||
.get("/_builder/api/apps", async ctx => {
|
|
||||||
ctx.body = await getApps(config, ctx.master)
|
|
||||||
ctx.response.status = StatusCodes.OK
|
|
||||||
})
|
|
||||||
.get("/_builder/api/:appname/appPackage", async ctx => {
|
|
||||||
const application = await ctx.master.getApplicationWithInstances(
|
|
||||||
ctx.params.appname
|
|
||||||
)
|
|
||||||
ctx.body = await getPackageForBuilder(config, application)
|
|
||||||
ctx.response.status = StatusCodes.OK
|
|
||||||
})
|
|
||||||
.get("/_builder/api/:appname/components", async ctx => {
|
|
||||||
try {
|
|
||||||
ctx.body = getComponentDefinitions(
|
|
||||||
config,
|
|
||||||
ctx.params.appname,
|
ctx.params.appname,
|
||||||
ctx.query.lib
|
ctx.query.lib
|
||||||
)
|
)
|
||||||
ctx.response.status = StatusCodes.OK
|
await send(ctx, info.components._lib || "index.js", { root: info.libDir })
|
||||||
} catch (e) {
|
})
|
||||||
if (e.status) {
|
.get("/_builder/*", async (ctx, next) => {
|
||||||
ctx.response.status = e.status
|
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 {
|
} else {
|
||||||
throw e
|
await send(ctx, "/index.html", { root: builderPath })
|
||||||
}
|
}
|
||||||
}
|
})
|
||||||
})
|
|
||||||
.get("/_builder/api/:appname/componentlibrary", async ctx => {
|
|
||||||
const info = await componentLibraryInfo(
|
|
||||||
config,
|
|
||||||
ctx.params.appname,
|
|
||||||
ctx.query.lib ? decodeURI(ctx.query.lib) : ""
|
|
||||||
)
|
|
||||||
ctx.body = info.components
|
|
||||||
ctx.response.status = StatusCodes.OK
|
|
||||||
})
|
|
||||||
.post("/_builder/api/:appname/backend", async ctx => {
|
|
||||||
await saveBackend(
|
|
||||||
config,
|
|
||||||
ctx.params.appname,
|
|
||||||
ctx.request.body.appDefinition,
|
|
||||||
ctx.request.body.accessLevels
|
|
||||||
)
|
|
||||||
ctx.master.deleteLatestPackageFromCache(ctx.params.appname)
|
|
||||||
ctx.response.status = StatusCodes.OK
|
|
||||||
})
|
|
||||||
.post("/_builder/api/:appname/pages/:pageName", async ctx => {
|
|
||||||
await buildPage(
|
|
||||||
config,
|
|
||||||
ctx.params.appname,
|
|
||||||
ctx.params.pageName,
|
|
||||||
ctx.request.body
|
|
||||||
)
|
|
||||||
ctx.response.status = StatusCodes.OK
|
|
||||||
})
|
|
||||||
.get("/_builder/api/:appname/pages/:pagename/screens", async ctx => {
|
|
||||||
ctx.body = await listScreens(
|
|
||||||
config,
|
|
||||||
ctx.params.appname,
|
|
||||||
ctx.params.pagename
|
|
||||||
)
|
|
||||||
ctx.response.status = StatusCodes.OK
|
|
||||||
})
|
|
||||||
.post("/_builder/api/:appname/pages/:pagename/screen", async ctx => {
|
|
||||||
ctx.body = await saveScreen(
|
|
||||||
config,
|
|
||||||
ctx.params.appname,
|
|
||||||
ctx.params.pagename,
|
|
||||||
ctx.request.body
|
|
||||||
)
|
|
||||||
ctx.response.status = StatusCodes.OK
|
|
||||||
})
|
|
||||||
.patch("/_builder/api/:appname/pages/:pagename/screen", async ctx => {
|
|
||||||
await renameScreen(
|
|
||||||
config,
|
|
||||||
ctx.params.appname,
|
|
||||||
ctx.params.pagename,
|
|
||||||
ctx.request.body.oldname,
|
|
||||||
ctx.request.body.newname
|
|
||||||
)
|
|
||||||
ctx.response.status = StatusCodes.OK
|
|
||||||
})
|
|
||||||
.delete("/_builder/api/:appname/pages/:pagename/screen/*", async ctx => {
|
|
||||||
const name = ctx.request.path.replace(
|
|
||||||
`/_builder/api/${ctx.params.appname}/pages/${ctx.params.pagename}/screen/`,
|
|
||||||
""
|
|
||||||
)
|
|
||||||
|
|
||||||
await deleteScreen(
|
router.use(userRoutes.routes());
|
||||||
config,
|
router.use(userRoutes.allowedMethods());
|
||||||
ctx.params.appname,
|
router.use(appsRoutes.routes())
|
||||||
ctx.params.pagename,
|
router.use(appsRoutes.allowedMethods());
|
||||||
decodeURI(name)
|
router.use(componentRoutes.routes());
|
||||||
)
|
router.use(componentRoutes.allowedMethods());
|
||||||
|
router.use(pageRoutes.routes());
|
||||||
|
router.use(pageRoutes.allowedMethods());
|
||||||
|
|
||||||
ctx.response.status = StatusCodes.OK
|
router
|
||||||
})
|
|
||||||
.get("/:appname", async ctx => {
|
.get("/:appname", async ctx => {
|
||||||
await send(ctx, "/index.html", { root: ctx.publicPath })
|
await send(ctx, "/index.html", { root: ctx.publicPath })
|
||||||
})
|
})
|
||||||
.get("/:appname/*", routeHandlers.appDefault)
|
.get("/:appname/*", routeHandlers.appDefault)
|
||||||
.get("/_builder/instance/:appname/:instanceid/*", routeHandlers.appDefault)
|
.get("/_builder/instance/:appname/:instanceid/*", routeHandlers.appDefault)
|
||||||
// EVERYTHING BELOW HERE REQUIRES AUTHENTICATION
|
|
||||||
.use(async (ctx, next) => {
|
router.use(authenticatedRoutes.routes());
|
||||||
if (ctx.isAuthenticated) {
|
router.use(authenticatedRoutes.allowedMethods());
|
||||||
await next()
|
|
||||||
} else {
|
|
||||||
ctx.response.status = StatusCodes.UNAUTHORIZED
|
|
||||||
}
|
|
||||||
})
|
|
||||||
.post(
|
|
||||||
"/_builder/instance/:appname/:instanceid/api/upgradeData",
|
|
||||||
routeHandlers.upgradeData
|
|
||||||
)
|
|
||||||
.post("/:appname/api/changeMyPassword", routeHandlers.changeMyPassword)
|
|
||||||
.post(
|
|
||||||
"/_builder/instance/:appname/:instanceid/api/changeMyPassword",
|
|
||||||
routeHandlers.changeMyPassword
|
|
||||||
)
|
|
||||||
.post(
|
|
||||||
"/:appname/api/executeAction/:actionname",
|
|
||||||
routeHandlers.executeAction
|
|
||||||
)
|
|
||||||
.post(
|
|
||||||
"/_builder/instance/:appname/:instanceid/api/executeAction/:actionname",
|
|
||||||
routeHandlers.executeAction
|
|
||||||
)
|
|
||||||
.post("/:appname/api/createUser", routeHandlers.createUser)
|
|
||||||
.post(
|
|
||||||
"/_builder/instance/:appname/:instanceid/api/createUser",
|
|
||||||
routeHandlers.createUser
|
|
||||||
)
|
|
||||||
.post("/:appname/api/enableUser", routeHandlers.enableUser)
|
|
||||||
.post(
|
|
||||||
"/_builder/instance/:appname/:instanceid/api/enableUser",
|
|
||||||
routeHandlers.enableUser
|
|
||||||
)
|
|
||||||
.post("/:appname/api/disableUser", routeHandlers.disableUser)
|
|
||||||
.post(
|
|
||||||
"/_builder/instance/:appname/:instanceid/api/disableUser",
|
|
||||||
routeHandlers.disableUser
|
|
||||||
)
|
|
||||||
.get("/:appname/api/users", routeHandlers.getUsers)
|
|
||||||
.get(
|
|
||||||
"/_builder/instance/:appname/:instanceid/api/users",
|
|
||||||
routeHandlers.getUsers
|
|
||||||
)
|
|
||||||
.get("/:appname/api/accessLevels", routeHandlers.getAccessLevels)
|
|
||||||
.get(
|
|
||||||
"/_builder/instance/:appname/:instanceid/api/accessLevels",
|
|
||||||
routeHandlers.getAccessLevels
|
|
||||||
)
|
|
||||||
.get("/:appname/api/listRecords/*", routeHandlers.listRecordsGet)
|
|
||||||
.get(
|
|
||||||
"/_builder/instance/:appname/:instanceid/api/listRecords/*",
|
|
||||||
routeHandlers.listRecordsGet
|
|
||||||
)
|
|
||||||
.post("/:appname/api/listRecords/*", routeHandlers.listRecordsPost)
|
|
||||||
.post(
|
|
||||||
"/_builder/instance/:appname/:instanceid/api/listRecords/*",
|
|
||||||
routeHandlers.listRecordsPost
|
|
||||||
)
|
|
||||||
.post("/:appname/api/aggregates/*", routeHandlers.aggregatesPost)
|
|
||||||
.post(
|
|
||||||
"/_builder/instance/:appname/:instanceid/api/aggregates/*",
|
|
||||||
routeHandlers.aggregatesPost
|
|
||||||
)
|
|
||||||
.post("/:appname/api/files/*", routeHandlers.postFiles)
|
|
||||||
.post(
|
|
||||||
"/_builder/instance/:appname/:instanceid/api/files/*",
|
|
||||||
routeHandlers.postFiles
|
|
||||||
)
|
|
||||||
.post("/:appname/api/record/*", routeHandlers.saveRecord)
|
|
||||||
.post(
|
|
||||||
"/_builder/instance/:appname/:instanceid/api/record/*",
|
|
||||||
routeHandlers.saveRecord
|
|
||||||
)
|
|
||||||
.get("/:appname/api/lookup_field/*", routeHandlers.lookupField)
|
|
||||||
.get(
|
|
||||||
"/_builder/instance/:appname/:instanceid/api/lookup_field/*",
|
|
||||||
routeHandlers.lookupField
|
|
||||||
)
|
|
||||||
.get("/:appname/api/record/*", routeHandlers.getRecord)
|
|
||||||
.get(
|
|
||||||
"/_builder/instance/:appname/:instanceid/api/record/*",
|
|
||||||
routeHandlers.getRecord
|
|
||||||
)
|
|
||||||
.del("/:appname/api/record/*", routeHandlers.deleteRecord)
|
|
||||||
.del(
|
|
||||||
"/_builder/instance/:appname/:instanceid/api/record/*",
|
|
||||||
routeHandlers.deleteRecord
|
|
||||||
)
|
|
||||||
.post("/:appname/api/apphierarchy", routeHandlers.saveAppHierarchy)
|
|
||||||
|
|
||||||
return router
|
return router
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,37 @@
|
||||||
|
const Router = require("@koa/router");
|
||||||
|
const StatusCodes = require("../../utilities/statusCodes")
|
||||||
|
const {
|
||||||
|
getPackageForBuilder,
|
||||||
|
getApps,
|
||||||
|
} = require("../../utilities/builder")
|
||||||
|
|
||||||
|
|
||||||
|
const router = Router();
|
||||||
|
|
||||||
|
router.get("/_builder/api/apps", async ctx => {
|
||||||
|
ctx.body = await getApps(ctx.config, ctx.master)
|
||||||
|
ctx.response.status = StatusCodes.OK
|
||||||
|
})
|
||||||
|
|
||||||
|
router.get("/_builder/api/:appname/appPackage", async ctx => {
|
||||||
|
const application = await ctx.master.getApplicationWithInstances(
|
||||||
|
ctx.params.appname
|
||||||
|
)
|
||||||
|
ctx.body = await getPackageForBuilder(ctx.config, application)
|
||||||
|
ctx.response.status = StatusCodes.OK
|
||||||
|
})
|
||||||
|
|
||||||
|
router
|
||||||
|
.post("/_builder/api/:appname/backend", async ctx => {
|
||||||
|
await saveBackend(
|
||||||
|
ctx.config,
|
||||||
|
ctx.params.appname,
|
||||||
|
ctx.request.body.appDefinition,
|
||||||
|
ctx.request.body.accessLevels
|
||||||
|
)
|
||||||
|
ctx.master.deleteLatestPackageFromCache(ctx.params.appname)
|
||||||
|
ctx.response.status = StatusCodes.OK
|
||||||
|
})
|
||||||
|
|
||||||
|
|
||||||
|
module.exports = router
|
|
@ -0,0 +1,132 @@
|
||||||
|
const Router = require("@koa/router");
|
||||||
|
const StatusCodes = require("../../utilities/statusCodes")
|
||||||
|
const routeHandlers = require("../routeHandlers")
|
||||||
|
|
||||||
|
const router = Router();
|
||||||
|
|
||||||
|
async function isAuthenticated(ctx, next) {
|
||||||
|
if (ctx.isAuthenticated) {
|
||||||
|
await next()
|
||||||
|
} else {
|
||||||
|
ctx.response.status = StatusCodes.UNAUTHORIZED
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
router.use(isAuthenticated)
|
||||||
|
|
||||||
|
router.post(
|
||||||
|
"/_builder/instance/:appname/:instanceid/api/upgradeData",
|
||||||
|
routeHandlers.upgradeData
|
||||||
|
)
|
||||||
|
|
||||||
|
router.post("/:appname/api/changeMyPassword", routeHandlers.changeMyPassword)
|
||||||
|
|
||||||
|
router.post(
|
||||||
|
"/_builder/instance/:appname/:instanceid/api/changeMyPassword",
|
||||||
|
routeHandlers.changeMyPassword
|
||||||
|
)
|
||||||
|
|
||||||
|
router.post(
|
||||||
|
"/:appname/api/executeAction/:actionname",
|
||||||
|
routeHandlers.executeAction
|
||||||
|
)
|
||||||
|
|
||||||
|
router.post(
|
||||||
|
"/_builder/instance/:appname/:instanceid/api/executeAction/:actionname",
|
||||||
|
routeHandlers.executeAction
|
||||||
|
)
|
||||||
|
|
||||||
|
router.post("/:appname/api/createUser", routeHandlers.createUser)
|
||||||
|
|
||||||
|
router.post(
|
||||||
|
"/_builder/instance/:appname/:instanceid/api/createUser",
|
||||||
|
routeHandlers.createUser
|
||||||
|
)
|
||||||
|
|
||||||
|
router.post("/:appname/api/enableUser", routeHandlers.enableUser)
|
||||||
|
|
||||||
|
router.post(
|
||||||
|
"/_builder/instance/:appname/:instanceid/api/enableUser",
|
||||||
|
routeHandlers.enableUser
|
||||||
|
)
|
||||||
|
|
||||||
|
router.post("/:appname/api/disableUser", routeHandlers.disableUser)
|
||||||
|
|
||||||
|
router.post(
|
||||||
|
"/_builder/instance/:appname/:instanceid/api/disableUser",
|
||||||
|
routeHandlers.disableUser
|
||||||
|
)
|
||||||
|
|
||||||
|
router.get("/:appname/api/users", routeHandlers.getUsers)
|
||||||
|
|
||||||
|
router.get(
|
||||||
|
"/_builder/instance/:appname/:instanceid/api/users",
|
||||||
|
routeHandlers.getUsers
|
||||||
|
)
|
||||||
|
|
||||||
|
router.get("/:appname/api/accessLevels", routeHandlers.getAccessLevels)
|
||||||
|
|
||||||
|
router.get(
|
||||||
|
"/_builder/instance/:appname/:instanceid/api/accessLevels",
|
||||||
|
routeHandlers.getAccessLevels
|
||||||
|
)
|
||||||
|
|
||||||
|
router.get("/:appname/api/listRecords/*", routeHandlers.listRecordsGet)
|
||||||
|
|
||||||
|
router.get(
|
||||||
|
"/_builder/instance/:appname/:instanceid/api/listRecords/*",
|
||||||
|
routeHandlers.listRecordsGet
|
||||||
|
)
|
||||||
|
|
||||||
|
router.post("/:appname/api/listRecords/*", routeHandlers.listRecordsPost)
|
||||||
|
|
||||||
|
router.post(
|
||||||
|
"/_builder/instance/:appname/:instanceid/api/listRecords/*",
|
||||||
|
routeHandlers.listRecordsPost
|
||||||
|
)
|
||||||
|
|
||||||
|
router.post("/:appname/api/aggregates/*", routeHandlers.aggregatesPost)
|
||||||
|
|
||||||
|
router.post(
|
||||||
|
"/_builder/instance/:appname/:instanceid/api/aggregates/*",
|
||||||
|
routeHandlers.aggregatesPost
|
||||||
|
)
|
||||||
|
|
||||||
|
router.post("/:appname/api/files/*", routeHandlers.postFiles)
|
||||||
|
|
||||||
|
router.post(
|
||||||
|
"/_builder/instance/:appname/:instanceid/api/files/*",
|
||||||
|
routeHandlers.postFiles
|
||||||
|
)
|
||||||
|
|
||||||
|
router.post("/:appname/api/record/*", routeHandlers.saveRecord)
|
||||||
|
|
||||||
|
router.post(
|
||||||
|
"/_builder/instance/:appname/:instanceid/api/record/*",
|
||||||
|
routeHandlers.saveRecord
|
||||||
|
)
|
||||||
|
|
||||||
|
router.get("/:appname/api/lookup_field/*", routeHandlers.lookupField)
|
||||||
|
|
||||||
|
router.get(
|
||||||
|
"/_builder/instance/:appname/:instanceid/api/lookup_field/*",
|
||||||
|
routeHandlers.lookupField
|
||||||
|
)
|
||||||
|
|
||||||
|
router.get("/:appname/api/record/*", routeHandlers.getRecord)
|
||||||
|
|
||||||
|
router.get(
|
||||||
|
"/_builder/instance/:appname/:instanceid/api/record/*",
|
||||||
|
routeHandlers.getRecord
|
||||||
|
)
|
||||||
|
|
||||||
|
router.del("/:appname/api/record/*", routeHandlers.deleteRecord)
|
||||||
|
|
||||||
|
router.del(
|
||||||
|
"/_builder/instance/:appname/:instanceid/api/record/*",
|
||||||
|
routeHandlers.deleteRecord
|
||||||
|
)
|
||||||
|
|
||||||
|
router.post("/:appname/api/apphierarchy", routeHandlers.saveAppHierarchy)
|
||||||
|
|
||||||
|
module.exports = router
|
|
@ -0,0 +1,48 @@
|
||||||
|
const Router = require("@koa/router");
|
||||||
|
const send = require("koa-send")
|
||||||
|
const StatusCodes = require("../../utilities/statusCodes")
|
||||||
|
const {
|
||||||
|
getComponentDefinitions,
|
||||||
|
componentLibraryInfo,
|
||||||
|
} = require("../../utilities/builder")
|
||||||
|
|
||||||
|
|
||||||
|
const router = Router();
|
||||||
|
|
||||||
|
router.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 })
|
||||||
|
})
|
||||||
|
|
||||||
|
router.get("/_builder/api/:appname/components", async ctx => {
|
||||||
|
try {
|
||||||
|
ctx.body = getComponentDefinitions(
|
||||||
|
ctx.config,
|
||||||
|
ctx.params.appname,
|
||||||
|
ctx.query.lib
|
||||||
|
)
|
||||||
|
ctx.response.status = StatusCodes.OK
|
||||||
|
} catch (e) {
|
||||||
|
if (e.status) {
|
||||||
|
ctx.response.status = e.status
|
||||||
|
} else {
|
||||||
|
throw e
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
router.get("/_builder/api/:appname/componentlibrary", async ctx => {
|
||||||
|
const info = await componentLibraryInfo(
|
||||||
|
ctx.config,
|
||||||
|
ctx.params.appname,
|
||||||
|
ctx.query.lib ? decodeURI(ctx.query.lib) : ""
|
||||||
|
)
|
||||||
|
ctx.body = info.components
|
||||||
|
ctx.response.status = StatusCodes.OK
|
||||||
|
})
|
||||||
|
|
||||||
|
module.exports = router
|
|
@ -0,0 +1,13 @@
|
||||||
|
const pageRoutes = require("./pages");
|
||||||
|
const componentRoutes = require("./components");
|
||||||
|
const userRoutes = require("./user");
|
||||||
|
const appsRoutes = require("./apps");
|
||||||
|
const authenticatedRoutes = require("./authenticated");
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
pageRoutes,
|
||||||
|
componentRoutes,
|
||||||
|
appsRoutes,
|
||||||
|
userRoutes,
|
||||||
|
authenticatedRoutes
|
||||||
|
};
|
|
@ -0,0 +1,73 @@
|
||||||
|
const Router = require("@koa/router");
|
||||||
|
const StatusCodes = require("../../utilities/statusCodes")
|
||||||
|
const {
|
||||||
|
listScreens,
|
||||||
|
saveScreen,
|
||||||
|
buildPage,
|
||||||
|
renameScreen,
|
||||||
|
deleteScreen
|
||||||
|
} = require("../../utilities/builder")
|
||||||
|
|
||||||
|
|
||||||
|
const router = Router()
|
||||||
|
|
||||||
|
router.post("/_builder/api/:appname/pages/:pageName", async ctx => {
|
||||||
|
await buildPage(
|
||||||
|
ctx.config,
|
||||||
|
ctx.params.appname,
|
||||||
|
ctx.params.pageName,
|
||||||
|
ctx.request.body
|
||||||
|
)
|
||||||
|
ctx.response.status = StatusCodes.OK
|
||||||
|
})
|
||||||
|
|
||||||
|
router.get("/_builder/api/:appname/pages/:pagename/screens", async ctx => {
|
||||||
|
ctx.body = await listScreens(
|
||||||
|
ctx.config,
|
||||||
|
ctx.params.appname,
|
||||||
|
ctx.params.pagename
|
||||||
|
)
|
||||||
|
ctx.response.status = StatusCodes.OK
|
||||||
|
})
|
||||||
|
|
||||||
|
router
|
||||||
|
.post("/_builder/api/:appname/pages/:pagename/screen", async ctx => {
|
||||||
|
ctx.body = await saveScreen(
|
||||||
|
ctx.config,
|
||||||
|
ctx.params.appname,
|
||||||
|
ctx.params.pagename,
|
||||||
|
ctx.request.body
|
||||||
|
)
|
||||||
|
ctx.response.status = StatusCodes.OK
|
||||||
|
})
|
||||||
|
|
||||||
|
router
|
||||||
|
.patch("/_builder/api/:appname/pages/:pagename/screen", async ctx => {
|
||||||
|
await renameScreen(
|
||||||
|
ctx.config,
|
||||||
|
ctx.params.appname,
|
||||||
|
ctx.params.pagename,
|
||||||
|
ctx.request.body.oldname,
|
||||||
|
ctx.request.body.newname
|
||||||
|
)
|
||||||
|
ctx.response.status = StatusCodes.OK
|
||||||
|
})
|
||||||
|
|
||||||
|
router
|
||||||
|
.delete("/_builder/api/:appname/pages/:pagename/screen/*", async ctx => {
|
||||||
|
const name = ctx.request.path.replace(
|
||||||
|
`/_builder/api/${ctx.params.appname}/pages/${ctx.params.pagename}/screen/`,
|
||||||
|
""
|
||||||
|
)
|
||||||
|
|
||||||
|
await deleteScreen(
|
||||||
|
ctx.config,
|
||||||
|
ctx.params.appname,
|
||||||
|
ctx.params.pagename,
|
||||||
|
decodeURI(name)
|
||||||
|
)
|
||||||
|
|
||||||
|
ctx.response.status = StatusCodes.OK
|
||||||
|
})
|
||||||
|
|
||||||
|
module.exports = router
|
|
@ -0,0 +1,33 @@
|
||||||
|
const Router = require("@koa/router")
|
||||||
|
const routeHandlers = require("../routeHandlers")
|
||||||
|
|
||||||
|
const router = new Router()
|
||||||
|
|
||||||
|
router.post("/:appname/api/authenticate", routeHandlers.authenticate)
|
||||||
|
|
||||||
|
router.post(
|
||||||
|
"/_builder/instance/:appname/:instanceid/api/authenticate",
|
||||||
|
routeHandlers.authenticate
|
||||||
|
)
|
||||||
|
|
||||||
|
router.post(
|
||||||
|
"/_builder/instance/:appname/:instanceid/api/setPasswordFromTemporaryCode",
|
||||||
|
routeHandlers.setPasswordFromTemporaryCode
|
||||||
|
)
|
||||||
|
|
||||||
|
router.post(
|
||||||
|
"/_builder/instance/:appname/:instanceid/api/createTemporaryAccess",
|
||||||
|
routeHandlers.createTemporaryAccess
|
||||||
|
)
|
||||||
|
|
||||||
|
router.post(
|
||||||
|
"/:appname/api/createTemporaryAccess",
|
||||||
|
routeHandlers.createTemporaryAccess
|
||||||
|
)
|
||||||
|
|
||||||
|
router.post(
|
||||||
|
"/:appname/api/setPasswordFromTemporaryCode",
|
||||||
|
routeHandlers.setPasswordFromTemporaryCode
|
||||||
|
)
|
||||||
|
|
||||||
|
module.exports = router
|
|
@ -131,10 +131,10 @@
|
||||||
lodash "^4.17.13"
|
lodash "^4.17.13"
|
||||||
to-fast-properties "^2.0.0"
|
to-fast-properties "^2.0.0"
|
||||||
|
|
||||||
"@budibase/client@^0.0.27":
|
"@budibase/client@^0.0.32":
|
||||||
version "0.0.27"
|
version "0.0.32"
|
||||||
resolved "https://registry.yarnpkg.com/@budibase/client/-/client-0.0.27.tgz#d43a66202a23103ae5ac89d9fa69c3cd36b2a090"
|
resolved "https://registry.yarnpkg.com/@budibase/client/-/client-0.0.32.tgz#76d9f147563a0bf939eae7f32ce75b2a527ba496"
|
||||||
integrity sha512-emS6L66fzfr/CdnpazlqveVKqcSQA9+sQRcbzLZ+sJLFk6FNIezRQcMjGHz+ooeYS91OVgOfleqXDCnvHO+MNg==
|
integrity sha512-jmCCLn0CUoQbL6h623S5IqK6+GYLqX3WzUTZInSb1SCBOM3pI0eLP5HwTR6s7r42SfD0v9jTWRdyTnHiElNj8A==
|
||||||
dependencies:
|
dependencies:
|
||||||
"@nx-js/compiler-util" "^2.0.0"
|
"@nx-js/compiler-util" "^2.0.0"
|
||||||
bcryptjs "^2.4.3"
|
bcryptjs "^2.4.3"
|
||||||
|
@ -145,10 +145,10 @@
|
||||||
shortid "^2.2.8"
|
shortid "^2.2.8"
|
||||||
svelte "^3.9.2"
|
svelte "^3.9.2"
|
||||||
|
|
||||||
"@budibase/core@^0.0.27":
|
"@budibase/core@^0.0.32":
|
||||||
version "0.0.27"
|
version "0.0.32"
|
||||||
resolved "https://registry.yarnpkg.com/@budibase/core/-/core-0.0.27.tgz#05bbacce692222089a1ae85b7ea4bb322e327f64"
|
resolved "https://registry.yarnpkg.com/@budibase/core/-/core-0.0.32.tgz#c5d9ab869c5e9596a1ac337aaf041e795b1cc7fa"
|
||||||
integrity sha512-V8qGB9Lcwz8CFGzYct6i1oI+WiYgEOCsBBQ6DPPRLLVg07i2DHI9Ynwa35QXWTO3WeyWIxy//WSmVwSlYPAtOw==
|
integrity sha512-B6DHlz/C/m3jrxHbImT4bphdJlL7r2qmGrmcVBSc9mGHvwcRh1xfFGrsPCOU2IEJow+DWD63BIjyHzLPI3cerQ==
|
||||||
dependencies:
|
dependencies:
|
||||||
"@nx-js/compiler-util" "^2.0.0"
|
"@nx-js/compiler-util" "^2.0.0"
|
||||||
bcryptjs "^2.4.3"
|
bcryptjs "^2.4.3"
|
||||||
|
|
Loading…
Reference in New Issue