-
Notifications
You must be signed in to change notification settings - Fork 81
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
add hooks to remove view configuration settings made on parent express application #115
base: master
Are you sure you want to change the base?
Conversation
Why not just |
I took your suggestion to heart and interpreted it this way. I renamed the object to |
Sorry, not sure I was clear. What I am saying is, there is already a documented option for Can you not simply use that? |
In short, no, using the I'll admit I could examine how those express settings were set prior and then restore them. But this doesn't seem like an ideal approach IMO. It would be better to "just work" out of the box with a template engine such as handlebars if that is possible. Backing up a little bit... Why are the If they are very important then I would recommend redesigning such that the set of default options passed into express are exposed for manipulation outside |
You can pass them to this module as options as documented in the API. If you do this, these will be as overrides immediately following the default settings such that you can undo whatever settings you didn't like. Your PR seems like duplication of this behavior. Example: Object.keys(settings = {
'x-powered-by': false,
'trust proxy': false,
'jsonp callback name': null,
'json replacer': null,
'json spaces': 0,
'case sensitive routing': false,
'strict routing': false,
'views': null,
'view cache': false,
'view engine': false
}).forEach(function (option) {
parent.set(option, settings[option]);
});
Object.keys(options.express).forEach(function (option) {
parent.set(option, options.express[option]);
}); |
Wait - I see your concern, sorry. I don't think this should be a big deal though. The express defaults should already be known no? |
thanks for seeing my concern :-) To be clear I don't need to go back to the express defaults, I need to go to the values set by another framework component (handlebars). IMO, the best way would be to be able to choose handlebars, and to choose swaggerize express, I wire them both up in my server.js, and it just works. But instead, the two framework components disagree about the three express settings, and the one who sets them last wins, leaving the other one in a very broken state. I'm going to send you another PR that is very simple, it will just delete the three properties that seem to be the root of the conflict from swaggerize-express. I think it's a better approach than what I've done on this one, as long as it's reasonable to sacrifice these options. I feel my experience level is not sufficient to make this call, so I will be curious to hear your opinion on it. |
I just tried it, the suggestion to run in production mode doesn't seem to On Sun, Nov 6, 2016 at 12:34 PM, Shaun Warman [email protected]
|
…d between defaults and passed in options.
I had to prevent swaggerize-express from configuring
views
,view cache
,view engine
on the express app in order to get the API to work in the same express app as our webserver. We only plan on running this way for development. What was happening is our template engine settings would get overwritten and then express couldn't serve ourhandlebars
templates.What I didn't know is is why those settings were placed there in the first place. I assumed it was to deliberately disable any view stuff based on the assumption the API runs all by itself within express. And that these are important settings. I relied on those assumptions when adding to the README. If I'm off base, I'd be willing to take a second pass at this.