Skip to content

Commit 95efe2f

Browse files
committed
[POC] Proxy Configuration Extension
1 parent 7b64b27 commit 95efe2f

File tree

1 file changed

+22
-3
lines changed

1 file changed

+22
-3
lines changed

lib/projectPreprocessor.js

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ class ProjectPreprocessor {
133133

134134
if (project.kind === "extension") {
135135
// Not a project but an extension
136-
// => remove it as from any known projects that depend on it
136+
// => remove it from any known projects that depend on it
137137
const parents = this.processedProjects[project.id].parents;
138138
for (let i = parents.length - 1; i >= 0; i--) {
139139
parents[i].dependencies.splice(parents[i].dependencies.indexOf(project), 1);
@@ -269,7 +269,7 @@ class ProjectPreprocessor {
269269
return false; // ignore this project
270270
}
271271

272-
if (project.specVersion !== "0.1" && project.specVersion !== "1.0") {
272+
if (project.specVersion !== "0.1" && project.specVersion !== "1.0" && project.specVersion !== "1.1a") {
273273
throw new Error(
274274
`Unsupported specification version ${project.specVersion} defined for project ` +
275275
`${project.id}. ` +
@@ -327,7 +327,8 @@ class ProjectPreprocessor {
327327

328328
if (!extension.specVersion) {
329329
throw new Error(`No specification version defined for extension ${extension.metadata.name}`);
330-
} else if (extension.specVersion !== "0.1" && extension.specVersion !== "1.0") {
330+
} else if (extension.specVersion !== "0.1" && extension.specVersion !== "1.0" &&
331+
extension.specVersion !== "1.1a") {
331332
throw new Error(
332333
`Unsupported specification version ${extension.specVersion} defined for extension ` +
333334
`${extension.metadata.name}. ` +
@@ -351,6 +352,13 @@ class ProjectPreprocessor {
351352
case "server-middleware":
352353
this.handleServerMiddleware(extension);
353354
break;
355+
case "proxy-configuration":
356+
if (extension.specVersion !== "1.1a") {
357+
throw new Error(`Extensions of type "proxy-configuration"
358+
must use specification version "1.1a"`);
359+
}
360+
this.handleProxyConfiguration(extension);
361+
break;
354362
default:
355363
throw new Error(`Unknown extension type '${extension.type}' for ${extension.id}`);
356364
}
@@ -511,6 +519,17 @@ class ProjectPreprocessor {
511519
const middlewarePath = path.join(extension.path, extension.middleware.path);
512520
middlewareRepository.addMiddleware(extension.metadata.name, middlewarePath);
513521
}
522+
523+
handleProxyConfiguration(extension) {
524+
if (!extension.metadata && !extension.metadata.name) {
525+
throw new Error(`Proxy configuration extension ${extension.id} is missing 'metadata.name' configuration`);
526+
}
527+
if (!extension.proxy || !extension.proxy.configuration) {
528+
throw new Error(`Proxy configuration extension ${extension.id} is missing 'proxy' configuration`);
529+
}
530+
const {proxyConfiguration} = require("@ui5/server");
531+
proxyConfiguration.addConfiguration(extension.metadata.name, extension.proxy.configuration);
532+
}
514533
}
515534

516535
/**

0 commit comments

Comments
 (0)