poeticninja / hapi-ninja

Boilerplate Hapi server example. Node.js, Hapi, and Swig.
MIT License
378 stars 56 forks source link

Integrating Mongoose structure #20

Closed khoi closed 8 years ago

khoi commented 8 years ago

Hi, I'm using your project structure and find that very helpful. Can you advice me on how would you structure this project adding mongoose integration. I would need to use models' logic in controllers. Could you help me on that?

dev0x10 commented 8 years ago

I think you can create two folders named 'controllers' and 'models' under /server Then, in your model folder put your mongoose model. Is this what you need or more specific?

poeticninja commented 8 years ago

Hi @khoiln! I have actually responded to someone with the same question here... https://github.com/hapijs/discuss/issues/100

I hope that helps. Please let me know if you have other questions but that should do it! :smile:

Also @dev0x10 just responded while I was typing this. Yeah, having a controllers folder and a models folder is a usually the simplest way and most common way to handle the folder structure. On really large projects it is nicer to have it broken down by section. Such as a users folder with the controllers and models of users. But I wouldn't worry about breaking it out like that until you have a LOT of stuff or many team members working on the project.

dev0x10 commented 8 years ago

Yes I'd agree. So, it depends on the project :+1:

khoi commented 8 years ago

Thanks alot @dev0x10 and @poeticninja :+1: