Skip to content

Commit

Permalink
[FEATURE] projectPreprocessor: Add handling for server-middleware ext…
Browse files Browse the repository at this point in the history
…ensions

As per RFC 0005: SAP/ui5-tooling#151
  • Loading branch information
RandomByte committed Jul 10, 2019
1 parent b5d4cfd commit aa26ec8
Show file tree
Hide file tree
Showing 5 changed files with 1,083 additions and 1,317 deletions.
16 changes: 16 additions & 0 deletions lib/projectPreprocessor.js
Original file line number Diff line number Diff line change
Expand Up @@ -348,6 +348,9 @@ class ProjectPreprocessor {
case "task":
this.handleTask(extension);
break;
case "server-middleware":
this.handleServerMiddleware(extension);
break;
default:
throw new Error(`Unknown extension type '${extension.type}' for ${extension.id}`);
}
Expand Down Expand Up @@ -495,6 +498,19 @@ class ProjectPreprocessor {

taskRepository.addTask(extension.metadata.name, task);
}

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);
}
}

/**
Expand Down
Loading

0 comments on commit aa26ec8

Please sign in to comment.