@apolitical/server
Version:
Node.js module to encapsulate Apolitical's express server setup
18 lines (16 loc) • 469 B
JavaScript
;
module.exports = () => {
return function load(app, { fallbackController, staticFiles }) {
if (staticFiles) {
const { baseUrl, indexFilePath } = staticFiles;
// Load fallback or static content
if (fallbackController) {
app.get(`${baseUrl}*`, fallbackController);
} else if (indexFilePath) {
app.get(`${baseUrl}*`, function (req, res) {
res.sendFile(indexFilePath);
});
}
}
};
};