Skip to content

Commit

Permalink
refact, please ignore
Browse files Browse the repository at this point in the history
  • Loading branch information
i5ting committed May 3, 2017
1 parent ca74ca5 commit 2bf120b
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 20 deletions.
27 changes: 14 additions & 13 deletions templates2/js/routes/index.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,19 @@
var router = require('koa-router')();

router.get('/', async function (ctx, next) {
ctx.state = {
title: 'koa2 title'
};
const router = require('koa-router')()

router.get('/', async (ctx, next) => {
await ctx.render('index', {
});
title: 'Hello Koa 2!'
})
})

router.get('/foo', async function (ctx, next) {
await ctx.render('index', {
title: 'koa2 foo'
});
});
router.get('/string', async (ctx, next) => {
ctx.body = 'koa2 string'
})

router.get('/json', async (ctx, next) => {
ctx.body = {
title: 'koa2 json'
}
})

module.exports = router;
module.exports = router
14 changes: 7 additions & 7 deletions templates2/js/routes/users.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
var router = require('koa-router')();
const router = require('koa-router')()

router.prefix('/users');
router.prefix('/users')

router.get('/', function (ctx, next) {
ctx.body = 'this is a users response!';
});
ctx.body = 'this is a users response!'
})

router.get('/bar', function (ctx, next) {
ctx.body = 'this is a users/bar response';
});
ctx.body = 'this is a users/bar response'
})

module.exports = router;
module.exports = router

0 comments on commit 2bf120b

Please sign in to comment.