From be533ddc740c77551c714836da08a651b81825b6 Mon Sep 17 00:00:00 2001 From: Alan Pearce Date: Sat, 8 Jul 2017 22:30:36 +0200 Subject: refactor: assign responders to actions via front controller --- src/app.js | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) (limited to 'src/app.js') diff --git a/src/app.js b/src/app.js index b6d8beb..912dda2 100644 --- a/src/app.js +++ b/src/app.js @@ -6,6 +6,7 @@ const app = new Koa(); const helmet = require("koa-helmet"); const actions = require("./actions.js"); +const responders = require("./responders.js"); const config = require("./modules/config.js"); @@ -19,9 +20,13 @@ module.exports = async function() { router.url("post", basename) ); - router.get("home", "/", actions.home(config, Posts.posts)); + router.get("home", "/", actions.home(config, responders.home, Posts.posts)); - router.get("posts", "/post", actions.posts(config, Posts.posts)); + router.get( + "posts", + "/post", + actions.posts(config, responders.list, Posts.posts) + ); router.get( "highlight-theme", @@ -29,13 +34,17 @@ module.exports = async function() { actions.highlightTheme(config) ); - router.get("post", "/post/:filename", actions.post(config, Posts.posts)); + router.get( + "post", + "/post/:filename", + actions.post(config, responders.post, Posts.posts) + ); for (let [term, items] of Posts.taxonomies) { router.get( `taxon-${term}`, `/${term}/:value`, - actions.taxonGenerator(config, term, items) + actions.taxonGenerator(config, responders.list, term, items) ); } -- cgit 1.4.1