Getting prettier running on the public routes.

This commit is contained in:
mike12345567 2022-02-22 17:38:27 +00:00
parent 4e522e39da
commit baf806275b
9 changed files with 64 additions and 74 deletions

View File

@ -1,5 +1,4 @@
node_modules
public
dist
*.spec.js
packages/builder/src/components/design/AppPreview/CurrentItemPreview.svelte

View File

@ -1,19 +1,9 @@
exports.search = () => {
exports.search = () => {}
}
exports.create = () => {}
exports.create = () => {
exports.read = () => {}
}
exports.update = () => {}
exports.read = () => {
}
exports.update = () => {
}
exports.delete = () => {
}
exports.delete = () => {}

View File

@ -1,7 +1,3 @@
exports.search = () => {
exports.search = () => {}
}
exports.execute = () => {
}
exports.execute = () => {}

View File

@ -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
// the call to be correct
function fixRow(row, params) {
@ -16,22 +18,19 @@ function fixRow(row, params) {
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)
}
exports.read = () => {
}
exports.read = () => {}
exports.update = async ctx => {
ctx.request.body = fixRow(ctx.request.body, ctx.params)
}
exports.delete = () => {
}
exports.delete = () => {}

View File

@ -1,19 +1,9 @@
exports.search = () => {
exports.search = () => {}
}
exports.create = () => {}
exports.create = () => {
exports.read = () => {}
}
exports.update = () => {}
exports.read = () => {
}
exports.update = () => {
}
exports.delete = () => {
}
exports.delete = () => {}

View File

@ -1,19 +1,9 @@
exports.search = () => {
exports.search = () => {}
}
exports.create = () => {}
exports.create = () => {
exports.read = () => {}
}
exports.update = () => {}
exports.read = () => {
}
exports.update = () => {
}
exports.delete = () => {
}
exports.delete = () => {}

View File

@ -4,20 +4,17 @@ const tableRoute = require("./tables")
const rowRoute = require("./rows")
const userRoute = require("./users")
const Router = require("@koa/router")
const usage = require("../../../middleware/usageQuota")
const PREFIX = "/api/public/v1"
const ROUTES = [
appRoute,
queryRoute,
tableRoute,
rowRoute,
userRoute
]
const ROUTES = [appRoute, queryRoute, tableRoute, rowRoute, userRoute]
const router = new Router({
prefix: PREFIX,
})
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.allowedMethods())
}

View File

@ -1,8 +1,16 @@
const Router = require("@koa/router")
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()
router.use(paramSubResource("tableId", "rowId"))
/**
* @openapi
* /tables/{tableId}/rows/search:
@ -119,7 +127,11 @@ const router = Router()
* search:
* $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
@ -152,7 +164,11 @@ router.post("/tables/:tableId/rows/search", controller.search)
* 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
@ -185,7 +201,11 @@ router.post("/tables/:tableId/rows", controller.create)
* 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
@ -209,7 +229,11 @@ router.put("/tables/:tableId/rows/:rowId", controller.update)
* 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
@ -233,6 +257,10 @@ router.delete("/tables/:tableId/rows/:rowId", controller.delete)
* 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

View File

@ -193,6 +193,7 @@ router
"/api/:tableId/rows",
paramResource("tableId"),
authorized(PermissionTypes.TABLE, PermissionLevels.WRITE),
usage,
rowController.patch
)
/**