metarhia / impress

Enterprise application server for Node.js and Metarhia private cloud ⚡
https://metarhia.com
MIT License
970 stars 129 forks source link

Application structure #872

Closed ykolomiets closed 6 years ago

ykolomiets commented 6 years ago

Hi, again) I have a question about structuring our application What is the best approach you recommend to use for stateful impress-server? I need some classes User, FightSession, some DAOs. Where can I place them? In application/test/lib and assign them as properties on global object api? How can I test my code?

tshemsedinov commented 6 years ago

Yes, best way is decomposing all reusable functions and classes into libraries and place them to applications/<name>/lib/<module>.js exporting everything to api. In this case testing will not be a problem, you can just require those modules to your tests so you can call everything without impress or prepare integration tests with impress, accessing your internal API with http/ws/jstp.

ykolomiets commented 6 years ago

@tshemsedinov, thanks! What is the difference between /applications/test/setup and /application/test/init? What is the main purpose of /application/test/model? Is there any documentation?

tshemsedinov commented 6 years ago

/setup is a place to for initial setup and migration scripts. /init scripts executes on app server startup. You do not need /model, in future it will be a place to hold subject-domain model schemas.