Permalink
Browse files

Setup as API with coffeescript and setup with Foreman

  • Loading branch information...
1 parent fdff705 commit 8ddb983d26338be7826f5deb18953e3d05297433 @skalnik committed Dec 31, 2011
Showing with 37 additions and 38 deletions.
  1. +1 −0 Procfile
  2. +3 −0 app.coffee
  3. +0 −35 app.js
  4. +31 −0 bin/server
  5. +2 −3 package.json
View
@@ -0,0 +1 @@
+web: ./node_modules/.bin/coffee bin/server -p $PORT
View
@@ -0,0 +1,3 @@
+exports.actions = (app, argv, options) ->
+ app.get '/', (req, res) ->
+ res.json {response: 'Success!'}, 200
View
35 app.js
@@ -1,35 +0,0 @@
-
-/**
- * Module dependencies.
- */
-
-var express = require('express')
- , routes = require('./routes')
-
-var app = module.exports = express.createServer();
-
-// Configuration
-
-app.configure(function(){
- app.set('views', __dirname + '/views');
- app.set('view engine', 'jade');
- app.use(express.bodyParser());
- app.use(express.methodOverride());
- app.use(app.router);
- app.use(express.static(__dirname + '/public'));
-});
-
-app.configure('development', function(){
- app.use(express.errorHandler({ dumpExceptions: true, showStack: true }));
-});
-
-app.configure('production', function(){
- app.use(express.errorHandler());
-});
-
-// Routes
-
-app.get('/', routes.index);
-
-app.listen(3000);
-console.log("Express server listening on port %d in %s mode", app.address().port, app.settings.env);
View
@@ -0,0 +1,31 @@
+express = require 'express'
+routes = require '../app'
+
+app = express.createServer();
+
+app.configure ->
+ app.use express.logger()
+ app.use express.bodyParser()
+ app.use express.methodOverride()
+ app.use app.router
+
+app.configure 'development', ->
+ app.use express.errorHandler({ dumpExceptions: true, showStack: true })
+
+app.configure 'production', ->
+ app.use express.errorHandler()
+
+argv = []
+options = {}
+for arg in process.argv
+ if arg.substr(0, 2) == '--'
+ parts = arg.split '='
+ options[parts[0].substr(2).replace('-','_')] = parts[1] || true
+ else
+ argv.push arg
+
+require('../app').actions app, argv, options
+port = options.port || 3000
+
+console.log "meme_gen server listening on port %d in %s mode", port, app.settings.env
+app.listen port
View
@@ -1,11 +1,10 @@
{
- "name": "application-name"
+ "name": "meme-gen"
, "version": "0.0.1"
, "private": true
, "dependencies": {
"express": "2.5.2"
, "jade": ">= 0.0.1"
- , "coffee-script": "~> 1.1.3"
- , "connect-assets": "~> 2.1.6"
+ , "coffee-script": "git://github.com/jashkenas/coffee-script.git"
}
}

0 comments on commit 8ddb983

Please sign in to comment.