Giter Club home page Giter Club logo

Comments (5)

DedrickEnc avatar DedrickEnc commented on May 27, 2024

Currently, we have 463 lines of code in our routes.js and we don't finish to add routes inside yet!

from bhima.

jniles avatar jniles commented on May 27, 2024

It should be noted that we will be removing some routes. For example, the following:

  app.get('/available_cost_center/', financeServices.availableCostCenters);                                                                                                                                                                                               
  app.get('/available_profit_center/', financeServices.availableProfitCenters);                                                                                                                                                                                           
  app.get('/cost/:id_project/:cc_id', financeServices.costCenterCost);                                                                                                                                                                                                    
  app.get('/profit/:id_project/:pc_id', financeServices.profitCenterCost);                                                                                                                                                                                                
  app.get('/costCenterAccount/:id_enterprise/:cost_center_id', financeServices.costCenterAccount);                                                                                                                                                                        
  app.get('/profitCenterAccount/:id_enterprise/:profit_center_id', financeServices.profitCenterAccount);                                                                                                                                                                  
  app.get('/removeFromCostCenter/:tab', financeServices.removeFromCostCenter);                                                                                                                                                                                            
  app.get('/removeFromProfitCenter/:tab', financeServices.removeFromProfitCenter);                                                                                                                                                                                        
  app.get('/auxiliairyCenterAccount/:id_enterprise/:auxiliairy_center_id', financeServices.auxCenterAccount);

However, I agree that we will have too many routes at the current rate.

from bhima.

jniles avatar jniles commented on May 27, 2024

@DedrickEnc, specifically addressing the routes question (not BLL/DAL layers).

We could break up the server architecture along self-contained modules. ExpressJS allows each module to configure a router which can then be exported and plugged into a main application router. It looks like this:

// inside routes.js
var cashboxes = require('./controllers/cashboxes');

/**
* This binds the /cashboxes URL to the methods  defined inside
* the cashboxes controller.  All matching sub-routes will be handled by
* that controller.
*/
app.use('/cashboxes', cashboxes);


/**
* Inside the file server/controllers/cashboxes.js
*/

var express = require('express');
var router = express.Router();

router.get('/', function list(req, res, next) { /* .. code .. */});
router.get('/:uuid', function detail(req, res, next) { /* .. code .. */});
router.post('/', function create(req, res, next) { /* .. code .. */});
// etc ...

// expose the router to the main server
module.exports = router;

For documentation on this method, see ExpressJS Routing.

In my opinion, the advantages are:

  1. Encourages modularity.
  2. Cleaner routes.js file
  3. Potential for module-level error handling

Disadvantages:

  1. Cannot view the entire app functionality in one file (as you an now with routes.js). We will need to include very explicit comments in routes.js to describe what each controller does.
  2. Where do shared modules (like journal.js) go?
  3. Full route definition not available in each module -- again, this can be fixed with comments. But we must be explicit that .get('/') in the cashboxes controller will actually match a GET request to the route '/cashboxes'.

from bhima.

DedrickEnc avatar DedrickEnc commented on May 27, 2024

We must take a decision by tomorrow, it must not be a pending design decision

from bhima.

DedrickEnc avatar DedrickEnc commented on May 27, 2024

No opportunity to use it for now, I close it!

from bhima.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.