Getting prettier running on the public routes.
This commit is contained in:
parent
4e522e39da
commit
baf806275b
|
@ -1,9 +1,8 @@
|
||||||
node_modules
|
node_modules
|
||||||
public
|
|
||||||
dist
|
dist
|
||||||
*.spec.js
|
*.spec.js
|
||||||
packages/builder/src/components/design/AppPreview/CurrentItemPreview.svelte
|
packages/builder/src/components/design/AppPreview/CurrentItemPreview.svelte
|
||||||
packages/server/builder
|
packages/server/builder
|
||||||
packages/server/coverage
|
packages/server/coverage
|
||||||
packages/server/client
|
packages/server/client
|
||||||
packages/builder/.routify
|
packages/builder/.routify
|
||||||
|
|
|
@ -1,19 +1,9 @@
|
||||||
exports.search = () => {
|
exports.search = () => {}
|
||||||
|
|
||||||
}
|
exports.create = () => {}
|
||||||
|
|
||||||
exports.create = () => {
|
exports.read = () => {}
|
||||||
|
|
||||||
}
|
exports.update = () => {}
|
||||||
|
|
||||||
exports.read = () => {
|
exports.delete = () => {}
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
exports.update = () => {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
exports.delete = () => {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
|
@ -1,7 +1,3 @@
|
||||||
exports.search = () => {
|
exports.search = () => {}
|
||||||
|
|
||||||
}
|
exports.execute = () => {}
|
||||||
|
|
||||||
exports.execute = () => {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
const rowController = require("../row")
|
||||||
|
|
||||||
// makes sure that the user doesn't need to pass in the type, tableId or _id params for
|
// makes sure that the user doesn't need to pass in the type, tableId or _id params for
|
||||||
// the call to be correct
|
// the call to be correct
|
||||||
function fixRow(row, params) {
|
function fixRow(row, params) {
|
||||||
|
@ -16,22 +18,19 @@ function fixRow(row, params) {
|
||||||
return row
|
return row
|
||||||
}
|
}
|
||||||
|
|
||||||
exports.search = () => {
|
exports.search = async ctx => {
|
||||||
|
await rowController.search(ctx)
|
||||||
|
console.log(ctx.body)
|
||||||
}
|
}
|
||||||
|
|
||||||
exports.create = () => {
|
exports.create = ctx => {
|
||||||
ctx.request.body = fixRow(ctx.request.body, ctx.params)
|
ctx.request.body = fixRow(ctx.request.body, ctx.params)
|
||||||
}
|
}
|
||||||
|
|
||||||
exports.read = () => {
|
exports.read = () => {}
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
exports.update = async ctx => {
|
exports.update = async ctx => {
|
||||||
ctx.request.body = fixRow(ctx.request.body, ctx.params)
|
ctx.request.body = fixRow(ctx.request.body, ctx.params)
|
||||||
}
|
}
|
||||||
|
|
||||||
exports.delete = () => {
|
exports.delete = () => {}
|
||||||
|
|
||||||
}
|
|
||||||
|
|
|
@ -1,19 +1,9 @@
|
||||||
exports.search = () => {
|
exports.search = () => {}
|
||||||
|
|
||||||
}
|
exports.create = () => {}
|
||||||
|
|
||||||
exports.create = () => {
|
exports.read = () => {}
|
||||||
|
|
||||||
}
|
exports.update = () => {}
|
||||||
|
|
||||||
exports.read = () => {
|
exports.delete = () => {}
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
exports.update = () => {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
exports.delete = () => {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
|
@ -1,19 +1,9 @@
|
||||||
exports.search = () => {
|
exports.search = () => {}
|
||||||
|
|
||||||
}
|
exports.create = () => {}
|
||||||
|
|
||||||
exports.create = () => {
|
exports.read = () => {}
|
||||||
|
|
||||||
}
|
exports.update = () => {}
|
||||||
|
|
||||||
exports.read = () => {
|
exports.delete = () => {}
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
exports.update = () => {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
exports.delete = () => {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
|
@ -4,20 +4,17 @@ const tableRoute = require("./tables")
|
||||||
const rowRoute = require("./rows")
|
const rowRoute = require("./rows")
|
||||||
const userRoute = require("./users")
|
const userRoute = require("./users")
|
||||||
const Router = require("@koa/router")
|
const Router = require("@koa/router")
|
||||||
|
const usage = require("../../../middleware/usageQuota")
|
||||||
|
|
||||||
const PREFIX = "/api/public/v1"
|
const PREFIX = "/api/public/v1"
|
||||||
const ROUTES = [
|
const ROUTES = [appRoute, queryRoute, tableRoute, rowRoute, userRoute]
|
||||||
appRoute,
|
|
||||||
queryRoute,
|
|
||||||
tableRoute,
|
|
||||||
rowRoute,
|
|
||||||
userRoute
|
|
||||||
]
|
|
||||||
|
|
||||||
const router = new Router({
|
const router = new Router({
|
||||||
prefix: PREFIX,
|
prefix: PREFIX,
|
||||||
})
|
})
|
||||||
for (let route of ROUTES) {
|
for (let route of ROUTES) {
|
||||||
|
// apply usage to everything, middleware will work out whats needs it
|
||||||
|
route.use(usage)
|
||||||
router.use(route.routes())
|
router.use(route.routes())
|
||||||
router.use(route.allowedMethods())
|
router.use(route.allowedMethods())
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,8 +1,16 @@
|
||||||
const Router = require("@koa/router")
|
const Router = require("@koa/router")
|
||||||
const controller = require("../../controllers/public/rows")
|
const controller = require("../../controllers/public/rows")
|
||||||
|
const authorized = require("../../../middleware/authorized")
|
||||||
|
const { paramSubResource } = require("../../../middleware/resourceId")
|
||||||
|
const {
|
||||||
|
PermissionLevels,
|
||||||
|
PermissionTypes,
|
||||||
|
} = require("@budibase/backend-core/permissions")
|
||||||
|
|
||||||
const router = Router()
|
const router = Router()
|
||||||
|
|
||||||
|
router.use(paramSubResource("tableId", "rowId"))
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @openapi
|
* @openapi
|
||||||
* /tables/{tableId}/rows/search:
|
* /tables/{tableId}/rows/search:
|
||||||
|
@ -119,7 +127,11 @@ const router = Router()
|
||||||
* search:
|
* search:
|
||||||
* $ref: '#/components/examples/rows'
|
* $ref: '#/components/examples/rows'
|
||||||
*/
|
*/
|
||||||
router.post("/tables/:tableId/rows/search", controller.search)
|
router.post(
|
||||||
|
"/tables/:tableId/rows/search",
|
||||||
|
authorized(PermissionTypes.TABLE, PermissionLevels.READ),
|
||||||
|
controller.search
|
||||||
|
)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @openapi
|
* @openapi
|
||||||
|
@ -152,7 +164,11 @@ router.post("/tables/:tableId/rows/search", controller.search)
|
||||||
* row:
|
* row:
|
||||||
* $ref: '#/components/examples/row'
|
* $ref: '#/components/examples/row'
|
||||||
*/
|
*/
|
||||||
router.post("/tables/:tableId/rows", controller.create)
|
router.post(
|
||||||
|
"/tables/:tableId/rows",
|
||||||
|
authorized(PermissionTypes.TABLE, PermissionLevels.WRITE),
|
||||||
|
controller.create
|
||||||
|
)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @openapi
|
* @openapi
|
||||||
|
@ -185,7 +201,11 @@ router.post("/tables/:tableId/rows", controller.create)
|
||||||
* row:
|
* row:
|
||||||
* $ref: '#/components/examples/row'
|
* $ref: '#/components/examples/row'
|
||||||
*/
|
*/
|
||||||
router.put("/tables/:tableId/rows/:rowId", controller.update)
|
router.put(
|
||||||
|
"/tables/:tableId/rows/:rowId",
|
||||||
|
authorized(PermissionTypes.TABLE, PermissionLevels.WRITE),
|
||||||
|
controller.update
|
||||||
|
)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @openapi
|
* @openapi
|
||||||
|
@ -209,7 +229,11 @@ router.put("/tables/:tableId/rows/:rowId", controller.update)
|
||||||
* row:
|
* row:
|
||||||
* $ref: '#/components/examples/row'
|
* $ref: '#/components/examples/row'
|
||||||
*/
|
*/
|
||||||
router.delete("/tables/:tableId/rows/:rowId", controller.delete)
|
router.delete(
|
||||||
|
"/tables/:tableId/rows/:rowId",
|
||||||
|
authorized(PermissionTypes.TABLE, PermissionLevels.WRITE),
|
||||||
|
controller.delete
|
||||||
|
)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @openapi
|
* @openapi
|
||||||
|
@ -233,6 +257,10 @@ router.delete("/tables/:tableId/rows/:rowId", controller.delete)
|
||||||
* row:
|
* row:
|
||||||
* $ref: '#/components/examples/row'
|
* $ref: '#/components/examples/row'
|
||||||
*/
|
*/
|
||||||
router.get("/tables/:tableId/rows/:rowId", controller.read)
|
router.get(
|
||||||
|
"/tables/:tableId/rows/:rowId",
|
||||||
|
authorized(PermissionTypes.TABLE, PermissionLevels.READ),
|
||||||
|
controller.read
|
||||||
|
)
|
||||||
|
|
||||||
module.exports = router
|
module.exports = router
|
||||||
|
|
|
@ -193,6 +193,7 @@ router
|
||||||
"/api/:tableId/rows",
|
"/api/:tableId/rows",
|
||||||
paramResource("tableId"),
|
paramResource("tableId"),
|
||||||
authorized(PermissionTypes.TABLE, PermissionLevels.WRITE),
|
authorized(PermissionTypes.TABLE, PermissionLevels.WRITE),
|
||||||
|
usage,
|
||||||
rowController.patch
|
rowController.patch
|
||||||
)
|
)
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in New Issue