2021-10-11 11:03:31 +00:00
|
|
|
const express = require('express');
|
|
|
|
const router = express.Router();
|
|
|
|
|
2021-11-11 15:18:31 +00:00
|
|
|
// middleware
|
2022-03-24 13:48:10 +00:00
|
|
|
const { auth, requireAuth, requireBody } = require('../middleware');
|
2021-11-11 15:18:31 +00:00
|
|
|
|
2021-10-11 11:03:31 +00:00
|
|
|
const {
|
|
|
|
getQueries,
|
|
|
|
addQuery,
|
|
|
|
deleteQuery,
|
2021-10-11 11:55:53 +00:00
|
|
|
updateQuery,
|
2021-10-11 11:03:31 +00:00
|
|
|
} = require('../controllers/queries/');
|
|
|
|
|
2022-03-24 13:48:10 +00:00
|
|
|
router
|
|
|
|
.route('/')
|
|
|
|
.post(
|
|
|
|
auth,
|
|
|
|
requireAuth,
|
|
|
|
requireBody(['name', 'prefix', 'template']),
|
|
|
|
addQuery
|
|
|
|
)
|
|
|
|
.get(getQueries);
|
|
|
|
|
2021-11-11 15:18:31 +00:00
|
|
|
router
|
|
|
|
.route('/:prefix')
|
|
|
|
.delete(auth, requireAuth, deleteQuery)
|
|
|
|
.put(auth, requireAuth, updateQuery);
|
2021-10-11 11:03:31 +00:00
|
|
|
|
|
|
|
module.exports = router;
|