diff --git a/core/controllers/questionController.js b/core/controllers/questionController.js new file mode 100644 index 0000000..cc23092 --- /dev/null +++ b/core/controllers/questionController.js @@ -0,0 +1,12 @@ +'use strict'; + +const Question = require('../models/question'); + +module.exports = class QuestionController { + + static showExample() { + let question = new Question(); + console.log(question.example()); + return question.example(); + } +}; \ No newline at end of file diff --git a/core/controllers/userController.js b/core/controllers/userController.js index 160ffbd..c28066c 100644 --- a/core/controllers/userController.js +++ b/core/controllers/userController.js @@ -5,7 +5,7 @@ const User = require('../models/user'); module.exports = class UserController { static hello () { let user = new User(); - user.setName('Wallef'); + user.setName('Ben'); return `Hello ${user.name}`; } diff --git a/core/models/question.js b/core/models/question.js new file mode 100644 index 0000000..3daf252 --- /dev/null +++ b/core/models/question.js @@ -0,0 +1,7 @@ +'use strict'; + +module.exports = class Question { + example () { + return 'this is an example'; + } +}; \ No newline at end of file diff --git a/core/routes.js b/core/routes.js index d8ff893..db5de6b 100644 --- a/core/routes.js +++ b/core/routes.js @@ -4,9 +4,14 @@ const Router = require('koa-router'); const router = new Router(); const UserController = require('./controllers/userController'); +const QuestionController = require('./controllers/questionController'); router.get('/', async ctx => { ctx.body = UserController.hello(); }); +router.get('/questions', async ctx => { + ctx.body = QuestionController.showExample(); +}); + module.exports = router; \ No newline at end of file