2020-06-12 21:42:55 +02:00
|
|
|
const Router = require("@koa/router")
|
2020-10-09 20:10:28 +02:00
|
|
|
const rowController = require("../controllers/row")
|
2020-06-12 21:42:55 +02:00
|
|
|
const authorized = require("../../middleware/authorized")
|
2020-10-06 20:13:41 +02:00
|
|
|
const usage = require("../../middleware/usageQuota")
|
2020-10-09 19:49:23 +02:00
|
|
|
const { READ_TABLE, WRITE_TABLE } = require("../../utilities/accessLevels")
|
2020-06-12 21:42:55 +02:00
|
|
|
|
|
|
|
const router = Router()
|
|
|
|
|
|
|
|
router
|
2020-09-29 13:02:06 +02:00
|
|
|
.get(
|
2020-10-09 20:10:28 +02:00
|
|
|
"/api/:tableId/:rowId/enrich",
|
2020-10-09 19:49:23 +02:00
|
|
|
authorized(READ_TABLE, ctx => ctx.params.tableId),
|
2020-10-09 20:10:28 +02:00
|
|
|
rowController.fetchEnrichedRow
|
2020-09-29 13:02:06 +02:00
|
|
|
)
|
2020-06-12 21:42:55 +02:00
|
|
|
.get(
|
2020-10-09 20:10:28 +02:00
|
|
|
"/api/:tableId/rows",
|
2020-10-09 19:49:23 +02:00
|
|
|
authorized(READ_TABLE, ctx => ctx.params.tableId),
|
2020-10-09 20:10:28 +02:00
|
|
|
rowController.fetchTableRows
|
2020-06-12 21:42:55 +02:00
|
|
|
)
|
|
|
|
.get(
|
2020-10-09 20:10:28 +02:00
|
|
|
"/api/:tableId/rows/:rowId",
|
2020-10-09 19:49:23 +02:00
|
|
|
authorized(READ_TABLE, ctx => ctx.params.tableId),
|
2020-10-09 20:10:28 +02:00
|
|
|
rowController.find
|
2020-06-12 21:42:55 +02:00
|
|
|
)
|
2020-10-09 20:10:28 +02:00
|
|
|
.post("/api/rows/search", rowController.search)
|
2020-06-12 21:42:55 +02:00
|
|
|
.post(
|
2020-10-09 20:10:28 +02:00
|
|
|
"/api/:tableId/rows",
|
2020-10-09 19:49:23 +02:00
|
|
|
authorized(WRITE_TABLE, ctx => ctx.params.tableId),
|
2020-10-06 20:13:41 +02:00
|
|
|
usage,
|
2020-10-09 20:10:28 +02:00
|
|
|
rowController.save
|
2020-06-12 21:42:55 +02:00
|
|
|
)
|
2020-09-10 10:36:14 +02:00
|
|
|
.patch(
|
2020-10-09 20:10:28 +02:00
|
|
|
"/api/:tableId/rows/:id",
|
2020-10-09 19:49:23 +02:00
|
|
|
authorized(WRITE_TABLE, ctx => ctx.params.tableId),
|
2020-10-09 20:10:28 +02:00
|
|
|
rowController.patch
|
2020-09-10 10:36:14 +02:00
|
|
|
)
|
2020-06-12 21:42:55 +02:00
|
|
|
.post(
|
2020-10-09 20:10:28 +02:00
|
|
|
"/api/:tableId/rows/validate",
|
2020-10-09 19:49:23 +02:00
|
|
|
authorized(WRITE_TABLE, ctx => ctx.params.tableId),
|
2020-10-09 20:10:28 +02:00
|
|
|
rowController.validate
|
2020-06-12 21:42:55 +02:00
|
|
|
)
|
|
|
|
.delete(
|
2020-10-09 20:10:28 +02:00
|
|
|
"/api/:tableId/rows/:rowId/:revId",
|
2020-10-09 19:49:23 +02:00
|
|
|
authorized(WRITE_TABLE, ctx => ctx.params.tableId),
|
2020-10-06 20:13:41 +02:00
|
|
|
usage,
|
2020-10-09 20:10:28 +02:00
|
|
|
rowController.destroy
|
2020-06-12 21:42:55 +02:00
|
|
|
)
|
|
|
|
|
|
|
|
module.exports = router
|