Layin ma bricks!
The commands below are meant to be run in a terminal; which should be easy enough to access if you're using a mac or a linux distribution. Using Windows will be a little trickier. You'll have to install a terminal-like program.
The Windows installer of Git comes with a terminal called git-bash. This should be enough to run these commands though you'll have to do some configuring so that the terminal is able to find the node
program.
If this is your first run of the server, we have to make sure the dependencies are installed:
npm
(Node Package Manager) that we'll use to install the dependencies.node-supervisor
with the command npm install -g supervisor
. This supervisor app will automatically restart the server whenever a file in the project changes. Makes developping a little smoother.packages.json
and run the command npm install
. This will install dependencies like express (our webserver), jade (an html template language), etc. into our project in the node_modules folder.To start the server run the command
make go
Visit http://localhost:3000/ in your browser to see the app.
See the Makefile
to add more targets as you see fit.
This should give an idea of how the code is structured.
app.js / app.coffee
This file is where the application starts. It's at the root of the project. It's mostly generated by express but you can adjust it. I rewrote app.js in coffeescript which is why there's an app.coffee. views/
This folder is where templates (html files) for pages should go. Express uses an HTML template language called Jade (jade-lang.org) which makes it easier to write HTML.routes/
This folder holds code that handles HTTP requests (like GET and POST) that the server receives. For example if I'm in a browser and I'm on the website for our app and I wanna go to www.oursite.com/home/
, the code that defines what's supposed to happen should be in this folder. home/
is called a routeservices/
Code in here is meant to run on the server. It's where any application-specific logic should go, like primer calculations, xml parsing, melting temperature calculations, etc. Code in this folder is not sent to the client's browser. Most probably the code in here is used by the route
handlers in the routes/
directory.assets/
This folder holds files (like images, css stylesheets, and javascript files) that get sent to the client's browser. You can reference these files in the jade templates from the views/
folder.