mirror of
https://github.com/directus/directus.git
synced 2026-01-29 07:27:57 -05:00
28 lines
659 B
TypeScript
28 lines
659 B
TypeScript
import { Router } from 'express';
|
|
import asyncHandler from 'express-async-handler';
|
|
import * as ExtensionsService from '../services/extensions';
|
|
import { RouteNotFoundException } from '../exceptions';
|
|
|
|
const router = Router();
|
|
|
|
router.get(
|
|
'/:type',
|
|
asyncHandler(async (req, res, next) => {
|
|
const typeAllowList = ['interfaces', 'layouts', 'displays', 'modules'];
|
|
|
|
if (typeAllowList.includes(req.params.type) === false) {
|
|
throw new RouteNotFoundException(req.path);
|
|
}
|
|
|
|
const interfaces = await ExtensionsService.listExtensions(req.params.type);
|
|
|
|
res.locals.payload = {
|
|
data: interfaces,
|
|
};
|
|
|
|
return next();
|
|
}),
|
|
);
|
|
|
|
export default router;
|