1
0
Fork 0
mirror of synced 2024-06-23 08:30:31 +12:00
budibase/packages/server/src/api/routes/record.js

50 lines
1.3 KiB
JavaScript
Raw Normal View History

const Router = require("@koa/router")
const recordController = require("../controllers/record")
const authorized = require("../../middleware/authorized")
const usage = require("../../middleware/usageQuota")
const { READ_TABLE, WRITE_TABLE } = require("../../utilities/accessLevels")
const router = Router()
router
.get(
"/api/:tableId/:recordId/enrich",
authorized(READ_TABLE, ctx => ctx.params.tableId),
recordController.fetchEnrichedRecord
)
.get(
"/api/:tableId/records",
authorized(READ_TABLE, ctx => ctx.params.tableId),
recordController.fetchTableRecords
)
.get(
"/api/:tableId/records/:recordId",
authorized(READ_TABLE, ctx => ctx.params.tableId),
recordController.find
)
2020-06-19 03:59:31 +12:00
.post("/api/records/search", recordController.search)
.post(
"/api/:tableId/records",
authorized(WRITE_TABLE, ctx => ctx.params.tableId),
usage,
recordController.save
)
2020-09-10 20:36:14 +12:00
.patch(
"/api/:tableId/records/:id",
authorized(WRITE_TABLE, ctx => ctx.params.tableId),
2020-09-11 08:11:05 +12:00
recordController.patch
2020-09-10 20:36:14 +12:00
)
.post(
"/api/:tableId/records/validate",
authorized(WRITE_TABLE, ctx => ctx.params.tableId),
recordController.validate
)
.delete(
"/api/:tableId/records/:recordId/:revId",
authorized(WRITE_TABLE, ctx => ctx.params.tableId),
usage,
recordController.destroy
)
module.exports = router