Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Support injecting middleware into generated app. #12

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from

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.

@@ -338,11 +338,12 @@ protected override CodeGenOutput GenerateOutputCore(ServiceInfo service)
}

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