express/application
app.defaultConfiguration = function defaultConfiguration() {
var env = process.env.NODE_ENV || "development";
// default settings
this.enable("x-powered-by");
this.set("etag", "weak");
this.set("env", env);
this.set("query parser", "extended");
this.set("subdomain offset", 2);
this.set("trust proxy", false);
/**
* subdomain offset : subdomain segment의 시작을 결정한다.
*
* 도메인 구성
*
* 1. Top-level domain(TLD) -> .com / .org
*
* 2. Second-level domain(SLD) -> naver / google
*
* subdomain
* SLD앞에 오는것
* 가장 공통적인 subdomain은 www이다.
*
* subdomain의 예: m.naver.com -> 'm'
*/
/**
* subdomain offset은 TLD부터 카운팅 하는것 같다.
* TLD(0) SLD(1) subdomain(2) 순서라 subdomain offset은 기본 2로 설정되는듯
*
* test2.localhost:4000과 같이 TLD가 없고, subdomain offset이 기본값(2)으로 설정되어 있는경우 subdomain을 가져올 수 없다고 한다.
*
* https://stackoverflow.com/questions/29146489/how-to-get-local-subdomains-using-express-js-s-req-subdomains 참고
*/
/**
* https://blog.hubspot.com/what-is-a-domain
*
* http:// -> 프로토콜
*
* blog. -> subdomain
*
* hubspot -> SLD
*
* .com -> TLD
*
* hubspot.com -> domain name
*
* /what-is-a-domain -> page path
*
* https://blog.hubspot.com/website/what-is-a-subdomain?toc-variant-a= 참고
*/
// trust proxy inherit back-compat
Object.defineProperty(this.settings, trustProxyDefaultSymbol, {
configurable: true,
value: true,
});
debug("booting in %s mode", env);
this.on("mount", function onmount(parent) {
// inherit trust proxy
if (
this.settings[trustProxyDefaultSymbol] === true &&
typeof parent.settings["trust proxy fn"] === "function"
) {
delete this.settings["trust proxy"];
delete this.settings["trust proxy fn"];
}
// inherit protos
setPrototypeOf(this.request, parent.request);
setPrototypeOf(this.response, parent.response);
setPrototypeOf(this.engines, parent.engines);
setPrototypeOf(this.settings, parent.settings);
});
// setup locals
this.locals = Object.create(null);
// top-most app is mounted at /
this.mountpath = "/";
// default locals
this.locals.settings = this.settings;
// default configuration
this.set("view", View);
this.set("views", resolve("views"));
this.set("jsonp callback name", "callback");
if (env === "production") {
this.enable("view cache");
}
Object.defineProperty(this, "router", {
get: function () {
throw new Error(
"'app.router' is deprecated!\nPlease see the 3.x to 4.x migration guide for details on how to update your app."
);
},
});
};