Skip to content

Commit

Permalink
adds canon.js passthrough for express settings
Browse files Browse the repository at this point in the history
  • Loading branch information
jhmullen committed Jun 24, 2022
1 parent 4a02af0 commit 8846f00
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 7 deletions.
15 changes: 9 additions & 6 deletions examples/canon.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,23 +12,23 @@ const pdfHeader = `data:image/png;base64,${buffer}`;
module.exports = {
sitemap: {
paths: {
profiles: '/:lang/profile/:profile/:page',
stories: '/:lang/story/:page'
profiles: "/:lang/profile/:profile/:page",
stories: "/:lang/story/:page"
},
rss: {
blogName: "My Datawheel blog",
blogDescription: "It is a fantastic blog based on data."
},
getMainPaths: async (app) => {
//You can run queries in here and return an array of paths
return [
getMainPaths: asyncapp =>
// You can run queries in here and return an array of paths
[
"/",
"/about",
"/about/data",
"/blog/es/super-post",
"/blog/en/super-posteo"
]
}

},
express: {
bodyParser: {
Expand All @@ -41,6 +41,9 @@ module.exports = {
}
}
}
},
set: {
"trust proxy": true
}
},
db: [
Expand Down
7 changes: 7 additions & 0 deletions packages/core/bin/server/steps/router.js
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,13 @@ module.exports = function(config) {

}

// user overrides of router keys
if (canonConfig.express.set) {
Object.keys(canonConfig.express.set).forEach(k => {
router.set(k, canonConfig.express.set[k]);
});
}

const reduxMiddleware = canonConfig.reduxMiddleware || false;
const App = require(path.join(staticPath, "assets/server"));
router.get("*", App.default(store, headerConfig, reduxMiddleware));
Expand Down
19 changes: 18 additions & 1 deletion pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 8846f00

Please sign in to comment.