mirror of
https://github.com/directus/directus.git
synced 2026-02-03 13:35:03 -05:00
Some examples of how to use
This commit is contained in:
@@ -32,6 +32,7 @@ router.get(
|
||||
'/:pk',
|
||||
useCollection('directus_activity'),
|
||||
sanitizeQuery,
|
||||
cacheMiddleware,
|
||||
asyncHandler(async (req, res) => {
|
||||
const service = new ActivityService({ accountability: req.accountability });
|
||||
const record = await service.readByKey(req.params.pk, req.sanitizedQuery);
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import { Router } from 'express';
|
||||
import asyncHandler from 'express-async-handler';
|
||||
import sanitizeQuery from '../middleware/sanitize-query';
|
||||
import cacheMiddleware from '../middleware/cache';
|
||||
import CollectionsService from '../services/collections';
|
||||
import useCollection from '../middleware/use-collection';
|
||||
import MetaService from '../services/meta';
|
||||
@@ -23,6 +24,7 @@ router.post(
|
||||
router.get(
|
||||
'/',
|
||||
useCollection('directus_collections'),
|
||||
cacheMiddleware,
|
||||
asyncHandler(async (req, res) => {
|
||||
const collectionsService = new CollectionsService({ accountability: req.accountability });
|
||||
const metaService = new MetaService({ accountability: req.accountability });
|
||||
@@ -38,6 +40,7 @@ router.get(
|
||||
'/:collection',
|
||||
useCollection('directus_collections'),
|
||||
sanitizeQuery,
|
||||
cacheMiddleware,
|
||||
asyncHandler(async (req, res) => {
|
||||
const collectionsService = new CollectionsService({ accountability: req.accountability });
|
||||
const collectionKey = req.params.collection.includes(',')
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import { Router } from 'express';
|
||||
import asyncHandler from 'express-async-handler';
|
||||
import cacheMiddleware from '../middleware/cache';
|
||||
import * as ExtensionsService from '../services/extensions';
|
||||
import { RouteNotFoundException } from '../exceptions';
|
||||
|
||||
@@ -7,6 +8,7 @@ const router = Router();
|
||||
|
||||
router.get(
|
||||
'/:type',
|
||||
cacheMiddleware,
|
||||
asyncHandler(async (req, res) => {
|
||||
const typeAllowList = ['interfaces', 'layouts', 'displays', 'modules'];
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@ import { Router } from 'express';
|
||||
import asyncHandler from 'express-async-handler';
|
||||
import FieldsService from '../services/fields';
|
||||
import validateCollection from '../middleware/collection-exists';
|
||||
import cacheMiddleware from '../middleware/cache';
|
||||
import { schemaInspector } from '../database';
|
||||
import { FieldNotFoundException, InvalidPayloadException } from '../exceptions';
|
||||
import Joi from 'joi';
|
||||
@@ -20,6 +21,7 @@ const router = Router();
|
||||
router.get(
|
||||
'/',
|
||||
useCollection('directus_fields'),
|
||||
cacheMiddleware,
|
||||
asyncHandler(async (req, res) => {
|
||||
const service = new FieldsService({ accountability: req.accountability });
|
||||
|
||||
@@ -32,6 +34,7 @@ router.get(
|
||||
'/:collection',
|
||||
validateCollection,
|
||||
useCollection('directus_fields'),
|
||||
cacheMiddleware,
|
||||
asyncHandler(async (req, res) => {
|
||||
const service = new FieldsService({ accountability: req.accountability });
|
||||
|
||||
|
||||
@@ -20,6 +20,7 @@ const cacheMiddleware: RequestHandler = asyncHandler(async (req, res, next) => {
|
||||
// make the key of the cache the URL
|
||||
// need to check that this will work for all endpoints
|
||||
// node cache service
|
||||
// have used query as then can decide whather to use cache or not from api call
|
||||
|
||||
if (!req.query.TTL) return next();
|
||||
if (!req.query.dTTL) return next();
|
||||
|
||||
Reference in New Issue
Block a user