Get Even More Visitors To Your Blog, Upgrade To A Business Listing >>

Two Applications, one (MongooseJS) MongoDB

Two Applications, one (MongooseJS) MongoDB

Problem

I have a service that loads data into a Mongodb on a regular basis and another one that is a Web Server for CRUD operations on that database. I'm using MongooseJS to preserve my sanity with working with MongoDB.

My question: How do I effectively and efficiently share the schemas across these services? I would love to not have to do some copy/paste action every time a change needs to be made.

TL;DR

Would creating a shared module do the trick? If so, I've never done that before, how could I do that effectively? Would I have all three modules in the same repo/directory and just run one file on one process and the other in another process?

My main goal is to prevent the importing service from bringing down the web Server service, which is why I'm splitting these out. I'm running on OpenShift and I'm thinking that I could have one server take care of the web server traffic and the other do the data import every 5 minutes or whatever needs to be done when.

I'd love some ideas on this! Thanks!

Problem courtesy of: kentcdodds

Solution

I decided to host my database on MongoHQ and just deploy the full code in two places, one which runs the background job, the other which runs the web app. I haven't implemented this quite yet, but I don't see why this wouldn't work.

Solution courtesy of: kentcdodds

Discussion

View additional discussion.



This post first appeared on Node.js Recipes, please read the originial post: here

Share the post

Two Applications, one (MongooseJS) MongoDB

×

Subscribe to Node.js Recipes

Get updates delivered right to your inbox!

Thank you for your subscription

×