1

Right now I have one Git repository for my whole web stack. I have the static files - the HTML files, JS libraries and Backbone.js app - being served from a directory, like, /project/static/js. I'm using Express's static file loading and pointing it at /project/static.

What I'd like to do is the break the project up into front end and back end repos, and when the Express server starts it loads the front end in and serves the static files. What's the best way to do this? I was thinking that I could put the front end in a Node module and have it installed with NPM from Github (or local via npm link) and then somehow reference the static files from that Node module. I've heard of tools like Grunt.js and I've read about using require.js with Node, but what's the right way to do this?

distorteddisco
  • 249
  • 2
  • 10
  • 1
    I *think* this is what I'm looking for: http://stackoverflow.com/questions/7746180/node-js-module-specific-static-resources – distorteddisco Feb 28 '13 at 16:59

1 Answers1

0

I would have 4 (or more) separated Git repositories. I prefer not to mix front-end project with backend project in the same repos. Separated client and backend into 2 separated projects will be cleaner, more portable and easy to be maintained. But if you would like to mix client and backend into one repo, make sure you organize your project into modules layout.

1) One repos for api only. Ex: myapp-api

2) One repos for web front end only. Ex: myapp-web. This repos will consume myapp-api. Make sure yours myapp-api take in some sort to tokens to authenticate a client (myapp-web in this case) to use apis

3) One repos for keys. Your app will need to access some sort of database, this repos will be shared between myapp-api and myapp-web

4) One repos for logger. This lib is used to log error and requests from clients, will be shared between myapp-api and myapp-web

hope this helps!

BenMorel
  • 34,448
  • 50
  • 182
  • 322
Nam Nguyen
  • 5,668
  • 14
  • 56
  • 70