Skip to content

Instantly share code, notes, and snippets.

@zachariahtimothy
Created April 24, 2013 19:49
Show Gist options
  • Save zachariahtimothy/5455017 to your computer and use it in GitHub Desktop.
Save zachariahtimothy/5455017 to your computer and use it in GitHub Desktop.
Express as an API application exported for interoperability with Grunt.
/**
* Module dependencies.
*/
var express = require('express');
var http = require('http');
var app = express();
// all environments
app.use(express.favicon());
app.use(express.logger('dev'));
app.use(express.bodyParser());
app.use(express.methodOverride());
app.use(express.cookieParser('your secret here'));
app.use(express.cookieSession({secret: 'cool cat', maxAge: 60 * 60 * 1000}));
app.use(app.router);
// development only
if ('development' === app.get('env')) {
app.use(express.errorHandler());
}
app.get('/', function (req, res) {
res.sendfile('app/index.html');
});
require('./routes')(app);
exports = module.exports = http.createServer(app);
exports.use = function() {
app.use.apply(app, arguments);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment