mirror of
https://github.com/directus/directus.git
synced 2026-04-03 03:00:39 -04:00
Pull in custom interfaces from the API
This commit is contained in:
@@ -1,27 +1,32 @@
|
||||
import { Router } from 'express';
|
||||
import express, { Router } from 'express';
|
||||
import asyncHandler from 'express-async-handler';
|
||||
import * as ExtensionsService from '../services/extensions';
|
||||
import { RouteNotFoundException } from '../exceptions';
|
||||
import ExtensionsService from '../services/extensions';
|
||||
import env from '../env';
|
||||
|
||||
const router = Router();
|
||||
|
||||
const extensionsPath = env.EXTENSIONS_PATH as string;
|
||||
router.use(express.static(extensionsPath));
|
||||
|
||||
router.get(
|
||||
'/:type',
|
||||
asyncHandler(async (req, res, next) => {
|
||||
const service = new ExtensionsService();
|
||||
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);
|
||||
const extensions = await service.listExtensions(req.params.type);
|
||||
|
||||
res.locals.payload = {
|
||||
data: interfaces,
|
||||
data: extensions,
|
||||
};
|
||||
|
||||
return next();
|
||||
}),
|
||||
})
|
||||
);
|
||||
|
||||
export default router;
|
||||
|
||||
Reference in New Issue
Block a user