Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
handleServerMiddleware(extension) {
if (!extension.metadata && !extension.metadata.name) {
throw new Error(`Middleware extension ${extension.id} is missing 'metadata.name' configuration`);
}
if (!extension.middleware) {
throw new Error(`Middleware extension ${extension.id} is missing 'middleware' configuration`);
}
const {middlewareRepository} = require("@ui5/server");
const middlewarePath = path.join(extension.path, extension.middleware.path);
middlewareRepository.addMiddleware(extension.metadata.name, middlewarePath);
}
}