I'm almost ashamed to ask this, but where can I find information about the settings for express.js? According to the documentation I can use app.set(name, setting) to assign setting name to setting, however I can't find anywhere which settings there are and how they work.
You can find it here:
http://expressjs.com/api.html#app-settings
settings
The following settings are provided to alter how Express will behave:
env Environment mode, defaults to process.env.NODE_ENV or "development"
trust proxy Enables reverse proxy support, disabled by default
jsonp callback name Changes the default callback name of ?callback=
json replacer JSON replacer callback, null by default
json spaces JSON response spaces for formatting, defaults to 2 in development, 0 in production
case sensitive routing Enable case sensitivity, disabled by default, treating "/Foo" and "/foo" as the same
strict routing Enable strict routing, by default "/foo" and "/foo/" are treated the same by the router
view cache Enables view template compilation caching, enabled in production by default
view engine The default engine extension to use when omitted
views The view directory path
Related
Is there a way in swagger 2 spec to disable “Try it out” in swaggerUI for specific paths.
I dont want to disable for all methods and paths, rather a specific method on a path.
Example - POST /files/upload
I have two websites, websiteEN and websiteDE.
They are both hosted on EC2 on their own instance.
their urls are : website.en and website.de
they use their own database websiteENDB and websiteDEDB.
I a currently using environment variables on AWS for their database.
To save money, I would like to host the two websites on the same instance.
I would need to get the database name from the url which is used to navigate the website.
How can I get the url with an express server and pass it to my config variable ?
EDIT :
Let's say for example that I have config.websiteDB = defaultDB
If a user is visiting the website from website.de, I would like to have config.websiteDB = websiteDEDB and if she is visiting the website from website.en, config.websiteDB = websiteENDB
Here is how we solved it.
We used,
https://github.com/mashpie/i18n-node
Also, you can use the same html template files and just have a different content for different languages.
Based on the language received from browser, you can choose appropriate database.
Hope it helps.
EDIT1:
If you check below, you can set your locales based on cookies, querystring parameter, fallback when a language content is not available etc.,
i18n.configure({
// setup some locales - other locales default to en silently
locales:['en', 'de'],
// fall back from Dutch to German
fallbacks:{'nl': 'de'},
// you may alter a site wide default locale
defaultLocale: 'de',
// sets a custom cookie name to parse locale settings from - defaults to NULL
cookie: 'yourcookiename',
// query parameter to switch locale (ie. /home?lang=ch) - defaults to NULL
queryParameter: 'lang',
// where to store json files - defaults to './locales' relative to modules directory
directory: './mylocales',
To set a cookie to desired language,
res.cookie('yourcookiename', 'de', { maxAge: 900000, httpOnly: true });
You can also use querystring parameters
/home?lang=ch
where lang is defined as a locale config parameter.
I need to generate dtos with swiftref but my API doesn´t has the path /types/swift like to http://techstacks.io/types/swift. I added the swift server configuration http://docs.servicestack.net/swift-add-servicestack-reference#swift-server-configuration in my AppHost but the path not work, Any idea?
Every ServiceStack AppHost supports exposing the Add ServiceStack Reference routes by default which is available from {baseUrl}/types/swift. You don't need to add any Swift Server configuration as it's enabled by default.
Make sure you're using the right baseUrl, which is also where the /metadata page is located. If you're using the right baseUrl check your ?debug=requestinfo for any Startup Errors, you will need to have DebugMode=true enabled.
Rather than having to change the URL passed in diet.listen() method on every server that I deploy my application on, there should be a better way to maintain such parameters in the application.
What options do we have to be able to manage such parameters?
You can create a '.json' file there at the root of the application and then do a require for the same. For example:
var configuration = require('./config.json');
The example expects you to save a file named 'config.json' with all your configuration as a JSON. The configuration object will hold all your settings that you might want to make dynamic and read at runtime.
I get the following message when i try to open a URL in UIWebView-
App Transport Security has blocked a cleartext HTTP (http://) resource load since it is insecure. Temporary exceptions can be configured via your app's Info.plist file.
I already tried the method given here but I get the same error report at the console
NSAppTransportSecurity add to info.plist , data type is Dictionary, then add an item NSAllowsArbitraryLoads , which is boolean value and set it to YES, then restart the Xcode project and run.
NSAppTransportSecurity: -
A dictionary containing the settings for overriding default App Transport Security behaviors. The top level key for the app’s Info.plist file.