mirror of
https://github.com/directus/directus.git
synced 2026-04-03 03:00:39 -04:00
44 lines
911 B
TypeScript
44 lines
911 B
TypeScript
import { Router } from 'express';
|
|
import { parseGraphQL } from '../middleware/graphql';
|
|
import { respond } from '../middleware/respond';
|
|
import { GraphQLService } from '../services';
|
|
import asyncHandler from '../utils/async-handler';
|
|
|
|
const router = Router();
|
|
|
|
router.use(
|
|
'/system',
|
|
parseGraphQL,
|
|
asyncHandler(async (req, res, next) => {
|
|
const service = new GraphQLService({
|
|
accountability: req.accountability,
|
|
schema: req.schema,
|
|
scope: 'system',
|
|
});
|
|
|
|
res.locals.payload = await service.execute(res.locals.graphqlParams);
|
|
|
|
return next();
|
|
}),
|
|
respond
|
|
);
|
|
|
|
router.use(
|
|
'/',
|
|
parseGraphQL,
|
|
asyncHandler(async (req, res, next) => {
|
|
const service = new GraphQLService({
|
|
accountability: req.accountability,
|
|
schema: req.schema,
|
|
scope: 'items',
|
|
});
|
|
|
|
res.locals.payload = await service.execute(res.locals.graphqlParams);
|
|
|
|
return next();
|
|
}),
|
|
respond
|
|
);
|
|
|
|
export default router;
|