2021-01-06 13:28:51 +01:00
|
|
|
const Router = require("@koa/router")
|
|
|
|
const queryController = require("../controllers/query")
|
|
|
|
const authorized = require("../../middleware/authorized")
|
|
|
|
const { BUILDER } = require("../../utilities/security/permissions")
|
2020-12-18 19:19:43 +01:00
|
|
|
|
2021-01-06 13:28:51 +01:00
|
|
|
const router = Router()
|
2020-12-18 19:19:43 +01:00
|
|
|
|
2021-01-06 13:28:51 +01:00
|
|
|
// TODO: sort out auth so apps have the right permissions
|
|
|
|
router
|
|
|
|
.get("/api/queries", authorized(BUILDER), queryController.fetch)
|
|
|
|
.post("/api/queries", authorized(BUILDER), queryController.save)
|
2021-01-08 19:22:03 +01:00
|
|
|
.post("/api/queries/preview", authorized(BUILDER), queryController.preview)
|
2021-01-11 18:18:22 +01:00
|
|
|
.post("/api/queries/:queryId", authorized(BUILDER), queryController.execute)
|
2021-01-06 13:28:51 +01:00
|
|
|
.delete("/api/queries/:queryId", authorized(BUILDER), queryController.destroy)
|
2020-12-18 19:19:43 +01:00
|
|
|
|
2021-01-06 13:28:51 +01:00
|
|
|
module.exports = router
|