mirror of
https://github.com/directus/directus.git
synced 2026-04-25 03:00:53 -04:00
Making sure delete is present
This commit is contained in:
@@ -5,6 +5,7 @@ import sanitizeQuery from '../middleware/sanitize-query';
|
||||
import useCollection from '../middleware/use-collection';
|
||||
import checkCacheMiddleware from '../middleware/check-cache';
|
||||
import setCacheMiddleware from '../middleware/set-cache';
|
||||
import delCacheMiddleware from '../middleware/delete-cache';
|
||||
import ActivityService from '../services/activity';
|
||||
import MetaService from '../services/meta';
|
||||
import { Action } from '../types';
|
||||
@@ -51,6 +52,7 @@ router.post(
|
||||
'/comment',
|
||||
useCollection('directus_activity'),
|
||||
sanitizeQuery,
|
||||
delCacheMiddleware,
|
||||
asyncHandler(async (req, res) => {
|
||||
const service = new ActivityService({ accountability: req.accountability });
|
||||
|
||||
@@ -74,6 +76,7 @@ router.patch(
|
||||
'/comment/:pk',
|
||||
useCollection('directus_activity'),
|
||||
sanitizeQuery,
|
||||
delCacheMiddleware,
|
||||
asyncHandler(async (req, res) => {
|
||||
const service = new ActivityService({ accountability: req.accountability });
|
||||
const primaryKey = await service.update(req.body, req.params.pk);
|
||||
@@ -88,6 +91,7 @@ router.patch(
|
||||
router.delete(
|
||||
'/comment/:pk',
|
||||
useCollection('directus_activity'),
|
||||
delCacheMiddleware,
|
||||
asyncHandler(async (req, res) => {
|
||||
const service = new ActivityService({ accountability: req.accountability });
|
||||
await service.delete(req.params.pk);
|
||||
|
||||
@@ -4,6 +4,7 @@ import asyncHandler from 'express-async-handler';
|
||||
import sanitizeQuery from '../middleware/sanitize-query';
|
||||
import checkCacheMiddleware from '../middleware/check-cache';
|
||||
import setCacheMiddleware from '../middleware/set-cache';
|
||||
import delCacheMiddleware from '../middleware/delete-cache';
|
||||
import CollectionsService from '../services/collections';
|
||||
import useCollection from '../middleware/use-collection';
|
||||
import MetaService from '../services/meta';
|
||||
@@ -13,6 +14,7 @@ const router = Router();
|
||||
router.post(
|
||||
'/',
|
||||
useCollection('directus_collections'),
|
||||
delCacheMiddleware,
|
||||
asyncHandler(async (req, res) => {
|
||||
const collectionsService = new CollectionsService({ accountability: req.accountability });
|
||||
|
||||
@@ -58,6 +60,7 @@ router.get(
|
||||
router.patch(
|
||||
'/:collection',
|
||||
useCollection('directus_collections'),
|
||||
delCacheMiddleware,
|
||||
asyncHandler(async (req, res) => {
|
||||
const collectionsService = new CollectionsService({ accountability: req.accountability });
|
||||
const collectionKey = req.params.collection.includes(',')
|
||||
@@ -72,6 +75,7 @@ router.patch(
|
||||
router.delete(
|
||||
'/:collection',
|
||||
useCollection('directus_collections'),
|
||||
delCacheMiddleware,
|
||||
asyncHandler(async (req, res) => {
|
||||
const collectionsService = new CollectionsService({ accountability: req.accountability });
|
||||
const collectionKey = req.params.collection.includes(',')
|
||||
|
||||
@@ -5,6 +5,7 @@ import FieldsService from '../services/fields';
|
||||
import validateCollection from '../middleware/collection-exists';
|
||||
import checkCacheMiddleware from '../middleware/check-cache';
|
||||
import setCacheMiddleware from '../middleware/set-cache';
|
||||
import delCacheMiddleware from '../middleware/delete-cache';
|
||||
import { schemaInspector } from '../database';
|
||||
import { FieldNotFoundException, InvalidPayloadException } from '../exceptions';
|
||||
import Joi from 'joi';
|
||||
@@ -85,6 +86,7 @@ router.post(
|
||||
'/:collection',
|
||||
validateCollection,
|
||||
useCollection('directus_fields'),
|
||||
delCacheMiddleware,
|
||||
asyncHandler(async (req, res) => {
|
||||
const service = new FieldsService({ accountability: req.accountability });
|
||||
|
||||
@@ -108,6 +110,7 @@ router.patch(
|
||||
'/:collection',
|
||||
validateCollection,
|
||||
useCollection('directus_fields'),
|
||||
delCacheMiddleware,
|
||||
asyncHandler(async (req, res) => {
|
||||
const service = new FieldsService({ accountability: req.accountability });
|
||||
|
||||
@@ -132,6 +135,7 @@ router.patch(
|
||||
'/:collection/:field',
|
||||
validateCollection,
|
||||
useCollection('directus_fields'),
|
||||
delCacheMiddleware,
|
||||
// @todo: validate field
|
||||
asyncHandler(async (req, res) => {
|
||||
const service = new FieldsService({ accountability: req.accountability });
|
||||
@@ -152,6 +156,7 @@ router.delete(
|
||||
'/:collection/:field',
|
||||
validateCollection,
|
||||
useCollection('directus_fields'),
|
||||
delCacheMiddleware,
|
||||
asyncHandler(async (req, res) => {
|
||||
const service = new FieldsService({ accountability: req.accountability });
|
||||
|
||||
|
||||
@@ -4,6 +4,7 @@ import asyncHandler from 'express-async-handler';
|
||||
import ItemsService from '../services/items';
|
||||
import checkCacheMiddleware from '../middleware/check-cache';
|
||||
import setCacheMiddleware from '../middleware/set-cache';
|
||||
import delCacheMiddleware from '../middleware/delete-cache';
|
||||
import sanitizeQuery from '../middleware/sanitize-query';
|
||||
import collectionExists from '../middleware/collection-exists';
|
||||
import MetaService from '../services/meta';
|
||||
@@ -15,6 +16,7 @@ router.post(
|
||||
'/:collection',
|
||||
collectionExists,
|
||||
sanitizeQuery,
|
||||
delCacheMiddleware,
|
||||
asyncHandler(async (req, res) => {
|
||||
if (req.singleton) {
|
||||
throw new RouteNotFoundException(req.path);
|
||||
@@ -76,6 +78,7 @@ router.patch(
|
||||
'/:collection',
|
||||
collectionExists,
|
||||
sanitizeQuery,
|
||||
delCacheMiddleware,
|
||||
asyncHandler(async (req, res) => {
|
||||
const service = new ItemsService(req.collection, { accountability: req.accountability });
|
||||
|
||||
@@ -96,6 +99,7 @@ router.patch(
|
||||
'/:collection/:pk',
|
||||
collectionExists,
|
||||
sanitizeQuery,
|
||||
delCacheMiddleware,
|
||||
asyncHandler(async (req, res) => {
|
||||
if (req.singleton) {
|
||||
throw new RouteNotFoundException(req.path);
|
||||
@@ -114,6 +118,7 @@ router.patch(
|
||||
router.delete(
|
||||
'/:collection/:pk',
|
||||
collectionExists,
|
||||
delCacheMiddleware,
|
||||
asyncHandler(async (req, res) => {
|
||||
const service = new ItemsService(req.collection, { accountability: req.accountability });
|
||||
const pk = req.params.pk.includes(',') ? req.params.pk.split(',') : req.params.pk;
|
||||
|
||||
@@ -5,6 +5,7 @@ import sanitizeQuery from '../middleware/sanitize-query';
|
||||
import PermissionsService from '../services/permissions';
|
||||
import useCollection from '../middleware/use-collection';
|
||||
import checkCacheMiddleware from '../middleware/check-cache';
|
||||
import delCacheMiddleware from '../middleware/delete-cache';
|
||||
import setCacheMiddleware from '../middleware/set-cache';
|
||||
import MetaService from '../services/meta';
|
||||
import { InvalidCredentialsException } from '../exceptions';
|
||||
@@ -16,6 +17,7 @@ router.use(useCollection('directus_permissions'));
|
||||
|
||||
router.post(
|
||||
'/',
|
||||
delCacheMiddleware,
|
||||
asyncHandler(async (req, res) => {
|
||||
const service = new PermissionsService({ accountability: req.accountability });
|
||||
const primaryKey = await service.create(req.body);
|
||||
@@ -82,6 +84,7 @@ router.get(
|
||||
|
||||
router.patch(
|
||||
'/:pk',
|
||||
delCacheMiddleware,
|
||||
asyncHandler(async (req, res) => {
|
||||
const service = new PermissionsService({ accountability: req.accountability });
|
||||
const primaryKey = await service.update(req.body, Number(req.params.pk));
|
||||
@@ -94,6 +97,7 @@ router.patch(
|
||||
|
||||
router.delete(
|
||||
'/:pk',
|
||||
delCacheMiddleware,
|
||||
asyncHandler(async (req, res) => {
|
||||
const service = new PermissionsService({ accountability: req.accountability });
|
||||
await service.delete(Number(req.params.pk));
|
||||
|
||||
Reference in New Issue
Block a user