Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

where to code business logic in nodejs with expressjs, mongoosejs and redis

My business logic includes mongodb operations and redis operations on one request. I do not know where we should put logic code to. In Java project, we have DAO, service and controler objects. but in nodejs projects, I don't know where to put my code. shall I put logic code to routes/index.js?

app.post('/deal', function(req, res) {
    ... //TODO: here

});

or create a kind of service objects such as what we do in Java proejct?

like image 241
Henry Leu Avatar asked Aug 26 '13 05:08

Henry Leu


1 Answers

Here's a question that might help: Mongoose-based app architecture

You should also look at the http://mean.io stack, as their templates will show you how to best structure your app, including where to store your logic.

like image 125
nevi_me Avatar answered Sep 17 '22 08:09

nevi_me