Commit 7679f837 authored by Sang D NGO's avatar Sang D NGO

Merge branch 'issue-8' into 'master'

#8 group webserver files by function

See merge request linagora/lgs/openpaas/linagora.esn.seed!10
parents 479318df d428edc9
......@@ -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
// }
// };
// }
};
......@@ -2,13 +2,12 @@
'use strict';
var MODULE_NAME = 'linagora.esn.seed';
var MODULE_PREFIX = 'seed';
angular.module(MODULE_NAME)
.config(seedApplicationMenu);
function seedApplicationMenu(dynamicDirectiveServiceProvider) {
var home = new dynamicDirectiveServiceProvider.DynamicDirective(true, MODULE_PREFIX + '-application-menu');
var home = new dynamicDirectiveServiceProvider.DynamicDirective(true, 'seed-application-menu');
dynamicDirectiveServiceProvider.addInjection('esn-application-menu', home);
}
......
......@@ -7,7 +7,7 @@ const glob = require('glob-all');
const FRONTEND_JS_PATH = __dirname + '/frontend/app/';
const AWESOME_MODULE_NAME = 'linagora.esn.seed';
const myAwesomeModule = new AwesomeModule(AWESOME_MODULE_NAME, {
const awesomeModule = new AwesomeModule(AWESOME_MODULE_NAME, {
dependencies: [
new Dependency(Dependency.TYPE_NAME, 'linagora.esn.core.logger', 'logger'),
new Dependency(Dependency.TYPE_NAME, 'linagora.esn.core.webserver.wrapper', 'webserver-wrapper'),
......@@ -66,4 +66,4 @@ const myAwesomeModule = new AwesomeModule(AWESOME_MODULE_NAME, {
* The main AwesomeModule describing the application.
* @type {AwesomeModule}
*/
module.exports = myAwesomeModule;
module.exports = awesomeModule;
......@@ -15,13 +15,13 @@ describe('The example API', function() {
if (err) {
return done(err);
}
const seedApp = require(self.testEnv.backendPath + '/webserver/application')(self.helpers.modules.current.deps);
const application = require(self.testEnv.backendPath + '/webserver/application')(self.helpers.modules.current.deps);
const api = require(self.testEnv.backendPath + '/webserver/api')(self.helpers.modules.current.deps, self.helpers.modules.current.lib.lib);
seedApp.use(require('body-parser').json());
seedApp.use('/api', api);
application.use(require('body-parser').json());
application.use('/api', api);
app = self.helpers.modules.getWebServer(seedApp);
app = self.helpers.modules.getWebServer(application);
self.helpers.api.applyDomainDeployment('linagora_IT', function(err, models) {
if (err) {
......
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