Skip to content

Commit

Permalink
Switched out Koa-frouter for Koa-Router
Browse files Browse the repository at this point in the history
  • Loading branch information
thedark1337 committed Aug 29, 2015
1 parent 209bf76 commit 0504117
Show file tree
Hide file tree
Showing 13 changed files with 56 additions and 13 deletions.
2 changes: 1 addition & 1 deletion routes/about.js → routes/about/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
'use strict';

exports.get = function *() {
module.exports = function *() {
yield this.render('about');
};
2 changes: 1 addition & 1 deletion routes/alpha.js → routes/alpha/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
'use strict';

exports.get = function *() {
module.exports = function *() {
yield this.render('alpha');
};
2 changes: 1 addition & 1 deletion routes/ambassadors.js → routes/ambassadors/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
'use strict';

exports.get = function *() {
module.exports = function *() {
yield this.render('ambassadors');
};
2 changes: 1 addition & 1 deletion routes/commands.js → routes/commands/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
'use strict';

exports.get = function *() {
module.exports = function *() {
yield this.render('commands');
};
2 changes: 1 addition & 1 deletion routes/donations.js → routes/donations/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
'use strict';

exports.get = function *() {
module.exports = function *() {
yield this.render('donations');
};
2 changes: 1 addition & 1 deletion routes/features.js → routes/features/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
'use strict';

exports.get = function *() {
module.exports = function *() {
yield this.render('features');
};
37 changes: 34 additions & 3 deletions routes/index.js
Original file line number Diff line number Diff line change
@@ -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;
5 changes: 5 additions & 0 deletions routes/index/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
'use strict';

module.exports = function *() {
yield this.render('index');
};
2 changes: 1 addition & 1 deletion routes/install.js → routes/install/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
'use strict';

exports.get = function *() {
module.exports = function *() {
yield this.render('install');
};
7 changes: 7 additions & 0 deletions routes/lang/index.js
Original file line number Diff line number Diff line change
@@ -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;
};
2 changes: 1 addition & 1 deletion routes/license.js → routes/license/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
'use strict';

exports.get = function *() {
module.exports = function *() {
yield this.render('license');
};
2 changes: 1 addition & 1 deletion routes/readme.js → routes/readme/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
'use strict';

exports.get = function *() {
module.exports = function *() {
yield this.render('install');
};
2 changes: 1 addition & 1 deletion routes/translate.js → routes/translate/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
'use strict';

exports.get = function *() {
module.exports = function *() {
yield this.render('translators');
};

0 comments on commit 0504117

Please sign in to comment.