Erik
Erik

Reputation: 14750

Is it possible to extend express application

Let me try to explain my purposes. I have a 3 subdomains of my site. All of them works similarly but has some difference.

So my question is can I write common express application with functions that has all subdomain applications and extend it out for each a subdomain application and add some specific features?

Upvotes: 0

Views: 187

Answers (1)

Richard Marr
Richard Marr

Reputation: 3064

Absolutely. The main problem is how to cleanly isolate domain-specific configuration from the application code.

One approach would be to use some middleware to detect which domain the request was inbound on and add the configuration specific to that domain to the request. That way each controller then only has to inspect the request to see how it should be treated. It can then pass some or all of that configuration to the data and templating layers.

Upvotes: 1

Related Questions