binki / autoserve

Deploy a node webapp to FastCGI, Passenger, node http, or other things in the future
Other
1 stars 0 forks source link

Configuration API #7

Open fbbdev opened 7 years ago

fbbdev commented 7 years ago

I'm opening this issue to summarize and discuss in one place all configuration APIs.

Things that currently are, or could be made, configurable:

Requirements:

Current APIs:

fbbdev commented 7 years ago

While I think that platform APIs (namely, register/override and the priority mechanism) reached a good point, I believe that options and base url APIs could be improved.

For options, I propose the following changes:

For the base url system I propose the following mechanism:

if (typeof module.exports.baseUrl === 'function') {
    actualBaseUrl = module.exports.baseUrl(req);
} else {
    actualBaseUrl = module.exports.baseUrl || detectedPlatform.getBaseUrl(req);
}
if (req.url.indexOf(actualBaseUrl) === 0) {
    req.baseUrl = actualBaseUrl;
    req.url = req.url.slice(actualBaseUrl.length);
}

These changes would allow a deployment script to handle complex cases while still providing sane defaults. See notes on cbccaf2 for a discussion of related problems.