diff --git a/routes/about.js b/routes/about/index.js similarity index 60% rename from routes/about.js rename to routes/about/index.js index 4ca4fdf..cbc8ad2 100644 --- a/routes/about.js +++ b/routes/about/index.js @@ -1,5 +1,5 @@ 'use strict'; -exports.get = function *() { +module.exports = function *() { yield this.render('about'); }; diff --git a/routes/alpha.js b/routes/alpha/index.js similarity index 60% rename from routes/alpha.js rename to routes/alpha/index.js index 92bc970..62610f2 100644 --- a/routes/alpha.js +++ b/routes/alpha/index.js @@ -1,5 +1,5 @@ 'use strict'; -exports.get = function *() { +module.exports = function *() { yield this.render('alpha'); }; diff --git a/routes/ambassadors.js b/routes/ambassadors/index.js similarity index 63% rename from routes/ambassadors.js rename to routes/ambassadors/index.js index bed4db3..44118eb 100644 --- a/routes/ambassadors.js +++ b/routes/ambassadors/index.js @@ -1,5 +1,5 @@ 'use strict'; -exports.get = function *() { +module.exports = function *() { yield this.render('ambassadors'); }; diff --git a/routes/commands.js b/routes/commands/index.js similarity index 62% rename from routes/commands.js rename to routes/commands/index.js index 3ab9e67..0df6f9a 100644 --- a/routes/commands.js +++ b/routes/commands/index.js @@ -1,5 +1,5 @@ 'use strict'; -exports.get = function *() { +module.exports = function *() { yield this.render('commands'); }; diff --git a/routes/donations.js b/routes/donations/index.js similarity index 62% rename from routes/donations.js rename to routes/donations/index.js index 74bdc59..38ab63b 100644 --- a/routes/donations.js +++ b/routes/donations/index.js @@ -1,5 +1,5 @@ 'use strict'; -exports.get = function *() { +module.exports = function *() { yield this.render('donations'); }; diff --git a/routes/features.js b/routes/features/index.js similarity index 62% rename from routes/features.js rename to routes/features/index.js index 3c77c49..8d50194 100644 --- a/routes/features.js +++ b/routes/features/index.js @@ -1,5 +1,5 @@ 'use strict'; -exports.get = function *() { +module.exports = function *() { yield this.render('features'); }; diff --git a/routes/index.js b/routes/index.js index 0304c3d..7c05080 100644 --- a/routes/index.js +++ b/routes/index.js @@ -1,5 +1,36 @@ 'use strict'; -exports.get = function *() { - yield this.render('index'); -}; +/* Route Dependencies */ + +const bodyParser = require('koa-body-parser'); +const router = require('koa-router')(); + +/* Route Files */ +const about = require('./about'); +const alpha = require('./alpha'); +const ambassadors = require('./ambassadors'); +const commands = require('./commands'); +const donations = require('./donations'); +const features = require('./features'); +const index = require('./index/'); +const install = require('./install'); +const lang = require('./lang'); +const license = require('./license'); +const readme = require('./readme'); +const translate = require('./translate'); + +/* Routes */ +router.get('/', index); +router.get('/about', about); +router.get('/alpha', alpha); +router.get('/ambassadors', ambassadors); +router.get('/commands', commands); +router.get('/donations', donations); +router.get('/features', features); +router.get('/install', install); +router.post('/lang', bodyParser(), lang); +router.get('/license', license); +router.get('/readme', readme); +router.get('/translate', translate); + +module.exports = router; diff --git a/routes/index/index.js b/routes/index/index.js new file mode 100644 index 0000000..88c2408 --- /dev/null +++ b/routes/index/index.js @@ -0,0 +1,5 @@ +'use strict'; + +module.exports = function *() { + yield this.render('index'); +}; diff --git a/routes/install.js b/routes/install/index.js similarity index 61% rename from routes/install.js rename to routes/install/index.js index 4377469..a6f89bd 100644 --- a/routes/install.js +++ b/routes/install/index.js @@ -1,5 +1,5 @@ 'use strict'; -exports.get = function *() { +module.exports = function *() { yield this.render('install'); }; diff --git a/routes/lang/index.js b/routes/lang/index.js new file mode 100644 index 0000000..55175eb --- /dev/null +++ b/routes/lang/index.js @@ -0,0 +1,7 @@ +'use strict'; + +module.exports = function *(next) { + const lang = this.request.body && this.request.body.lang || 'en'; + this.cookies.set('locale', lang); + this.status = 200; +}; diff --git a/routes/license.js b/routes/license/index.js similarity index 61% rename from routes/license.js rename to routes/license/index.js index 493b247..ca2c59b 100644 --- a/routes/license.js +++ b/routes/license/index.js @@ -1,5 +1,5 @@ 'use strict'; -exports.get = function *() { +module.exports = function *() { yield this.render('license'); }; diff --git a/routes/readme.js b/routes/readme/index.js similarity index 61% rename from routes/readme.js rename to routes/readme/index.js index 4377469..a6f89bd 100644 --- a/routes/readme.js +++ b/routes/readme/index.js @@ -1,5 +1,5 @@ 'use strict'; -exports.get = function *() { +module.exports = function *() { yield this.render('install'); }; diff --git a/routes/translate.js b/routes/translate/index.js similarity index 63% rename from routes/translate.js rename to routes/translate/index.js index bfcbf24..ce6999f 100644 --- a/routes/translate.js +++ b/routes/translate/index.js @@ -1,5 +1,5 @@ 'use strict'; -exports.get = function *() { +module.exports = function *() { yield this.render('translators'); };