Commit b4268859 authored by Sang D NGO's avatar Sang D NGO

#8 group webserver files by function

parent d5d41c2d
......@@ -2,12 +2,11 @@
// arguments: dependencies, lib
module.exports = function() {
return {
get
};
function example(req, res) {
function get(req, res) {
return res.status(200).json({ message: 'controller example' });
}
return {
example
};
};
'use strict';
module.exports = function(dependencies, lib, router) {
const authorizationMW = dependencies('authorizationMW');
const exampleController = require('../controllers/example')(dependencies, lib);
const controller = require('./controller')(dependencies, lib);
const middleware = require('./middleware')(dependencies, lib);
router.get('/example', authorizationMW.requiresAPILogin, exampleController.example);
router.get('/example',
authorizationMW.requiresAPILogin,
middleware.canGet,
controller.get);
};
......@@ -2,13 +2,12 @@
//arguments: dependencies, lib
module.exports = function() {
// arguments: req, res, next, clientId
function example(req, res) {
return res.status(200).json({ message: 'middleware example' });
}
return {
example
canGet
};
// arguments: req, res, next
function canGet(req, res, next) {
next();
}
};
'use strict';
module.exports = {
// define helpers that are shared by webserver file
// example:
// createErrorMessage: function(error, errDetail) {
// return {
// error: {
// code: 500,
// message: errDetail || 'Server Error',
// details: error.message
// }
// };
// }
};
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment