Sunday, 9 April 2017

Separate express api database from server.js file

I'm very newbie to Node.js and so is this question.

Im using this example please take a look at this link below.

https://github.com/sahat/newedenfaces-react/blob/master/server.js

In this server.js file the programmer is making call to

mongoose.connect(config.database);

app.get('/api/characters', function(req, res, next) {}

etc

all in server.js file

I want to keep everything cleaner

and just do the

server.listen(app.get('port'), function() {}

on server.js file and the rest of the things on some different file and import or stuff them.

Thanks.



via IMOBAMA

No comments:

Post a Comment