Search code examples
javascriptbackbone.jsexpressscaffolding

How should I scaffold this express & backbone application?


I never found an answer that really hit me so I'm just thought I'd put out this question and see what people thought. Here are the details of my app so far:

  1. Backend: Php Api serving up JSON
  2. Frontend:
    Express to serve up login / sales / signup / app pages
    Backbone / AMD to serve up the single page application

Questions:

  1. How should I scaffold this application?
  2. I will have backbone views for the signup and login page that work through express to connect to the API...where should these be and/or is this overkill?

All authentication happens through the api which passes back a session token.


Solution

  • Here is what I ended up doing:

    client /
      widgets / 
      views /
      models /
      collections / 
      login.coffee
      main.coffee
    client-dist / 
    server /
      views / 
      app.coffee
      config.coffee
    server-dist /
    

    Details:

    • Dist Directories: Build directories with compiled .coffee and .less files
    • Build Tool: Grunt.js --> see this issue for details on build config
    • Require Multi-Page Shim: I want to serve up multiple pages with AMD and followed the multi-page shim example provided by jrburke
    • Application Management: I used Addy Osmani's Aura framework that was modified to manage application pages and widgets

    The node express application is served up at server-dist/app.js and loads the proper .js file from the client-dist with requirejs.