├── README.md ├── app.coffee ├── app.js ├── public └── js │ └── script.js └── views ├── index.jade └── layout.jade /README.md: -------------------------------------------------------------------------------- 1 | # node-express-coffeescript 2 | 3 | A simple Node template with Express, CoffeeScript, Jade and Connect. 4 | 5 | ## Dependencies 6 | This template can be used to create [Node](http://nodejs.org) applications using; 7 | 8 | * [Express](http://expressjs.com) 9 | * [CoffeeScript](http://jashkenas.github.com/coffee-script) 10 | * [Jade](http://jade-lang.com/) 11 | * [Connect](http://senchalabs.github.com/connect/) 12 | 13 | ## Install 14 | 15 | ``` 16 | # Install Node and npm 17 | npm install connect 18 | npm install express 19 | npm install coffee-script 20 | npm install jade 21 | 22 | git clone http://github.com/alfrednerstu/node-express-coffeescript.git [project-name] 23 | cd [project-name] 24 | 25 | coffee app.coffee 26 | 27 | or 28 | 29 | node app.js 30 | 31 | ``` 32 | 33 | ## Thanks to 34 | 35 | * [Tom Wilson](https://github.com/twilson63) for express-coffee the original behind this template and readme 36 | * [Jeremy Ashkenas](https://github.com/jashkenas) for coffee-script 37 | * [TJ Holowaychuk](https://github.com/visionmedia) for express, jade and connect 38 | * [Ryan Dahl](https://github.com/ry) for node 39 | -------------------------------------------------------------------------------- /app.coffee: -------------------------------------------------------------------------------- 1 | connect = require 'connect' 2 | express = require 'express' 3 | jade = require 'jade' 4 | 5 | app = module.exports = express.createServer() 6 | 7 | # CONFIGURATION 8 | 9 | app.configure(() -> 10 | app.set 'view engine', 'jade' 11 | app.set 'views', "#{__dirname}/views" 12 | 13 | app.use connect.bodyParser() 14 | app.use connect.static(__dirname + '/public') 15 | app.use express.cookieParser() 16 | app.use express.session({secret : "shhhhhhhhhhhhhh!"}) 17 | app.use express.logger() 18 | app.use express.methodOverride() 19 | app.use app.router 20 | ) 21 | 22 | app.configure 'development', () -> 23 | app.use express.errorHandler({ 24 | dumpExceptions: true 25 | showStack : true 26 | }) 27 | 28 | app.configure 'production', () -> 29 | app.use express.errorHandler() 30 | 31 | # ROUTES 32 | 33 | app.get '/', (req, res) -> 34 | res.render 'index', 35 | locals: 36 | title: 'Hello World!' 37 | 38 | # SERVER 39 | 40 | app.listen(1234) 41 | console.log "Express server listening on port #{app.address().port}" -------------------------------------------------------------------------------- /app.js: -------------------------------------------------------------------------------- 1 | require("coffee-script"); 2 | require('./app.coffee'); -------------------------------------------------------------------------------- /public/js/script.js: -------------------------------------------------------------------------------- 1 | // Put your client side JS here -------------------------------------------------------------------------------- /views/index.jade: -------------------------------------------------------------------------------- 1 | header 2 | h1 Hello World! 3 | p 4 | |It works! 5 | 6 | -------------------------------------------------------------------------------- /views/layout.jade: -------------------------------------------------------------------------------- 1 | !!! 5 2 | html(lang="en") 3 | head 4 | meta(charset="utf-8") 5 | title= title 6 | script(src="/js/script.js") 7 | body 8 | != body --------------------------------------------------------------------------------