Skip to content

Support injecting middleware into generated app.#12

Closed
sportnak wants to merge 1 commit intoFacilityApi:masterfrom
sportnak:master
Closed

Support injecting middleware into generated app.#12
sportnak wants to merge 1 commit intoFacilityApi:masterfrom
sportnak:master

Conversation

@sportnak
Copy link

No description provided.

@ejball ejball requested a review from ddunkin October 30, 2018 03:33
Copy link
Contributor

@ddunkin ddunkin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could this instead be solved with a parent app? E.g.

const app = express();
app.use(myMiddleware);
app.use(createApp(service));

code.WriteLine("const app = express();");
code.WriteLine("app.use(bodyParser.json());");
code.WriteLine("app.use(bodyParser.urlencoded({ extended: true }));");
code.WriteLine("middleware.forEach(func => app.use(func));");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Test if middleware is truthy.


code.WriteLine();
using (code.Block("export function createApp(service" + IfTypeScript($": I{capModuleName}") + ")" + IfTypeScript(": express.Application") + " {", "}"))
using (code.Block("export function createApp(service" + IfTypeScript($": I{capModuleName}") + ", middleware" + IfTypeScript(": ((...args: any[]) => void)[]") + ")" + IfTypeScript(": express.Application") + " {", "}"))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

middleware should be optional.

@sportnak
Copy link
Author

Ah yeah, we could probably just do the parent app, thanks.

@sportnak sportnak closed this Oct 30, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants