Search code examples
node.jschaplinjs

Getting started with Chaplin and node.js


Is there a way to use Chaplin with node.js/express? I haven't found a single tutorial or an example on this subject.

If so, how do I get started? How would the folder structure look like? Or my server.js file?


Solution

  • Chaplin appears to be purely client side. For a basic app your back end could be a static HTML page. It requires no particular server structure.

    Backbone, which it's built on, expects a RESTful JSON API to persist its models, but otherwise doesn't require a backend either. If your app has models which need to be saved (likely), then you'll want to look into tutorials for writing a REST API in express (there are many) or for extending Backbone to suit your particular backend needs.

    So to get started, your server.js file will look exactly like the one created by the express install script.

    There's no de facto best practice for how to structure the folders in an end-to-end javascript app. In my experience I tend to keep client side javascript in its own folder (/client, /app/client, /lib/client, etc), then generate the publicly exposed compressed/concated scripts in a build step. To get started, you might just deposit them in /public/javascripts.