Skip to content

Commit

Permalink
startings recieving files
Browse files Browse the repository at this point in the history
  • Loading branch information
pokutnik committed Mar 30, 2013
1 parent 1b8cb67 commit 6a619b1
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 13 deletions.
23 changes: 12 additions & 11 deletions api_srv/app.coffee
Original file line number Diff line number Diff line change
@@ -1,36 +1,28 @@

express = require 'express'
routes = require './routes'
user = require './routes/user'
http = require 'http'
path = require 'path'
fs = require 'fs'
async = require 'async'
utils = require './utils'
User = require './models/user'

User = require './models/user'
utils = require './utils'

app = express()

app.configure ->
app.set 'port', process.env.PORT || 3000
app.set 'views', __dirname + '/views'
app.set 'view engine', 'jade'
app.use express.static(path.join(__dirname, 'public'))
app.use express.logger('dev')
app.use express.bodyParser()
app.use express.methodOverride()
app.use express.cookieParser('secret')
app.use express.session()

app.use utils.sessionLogging

app.use app.router
app.use require('less-middleware')({ src: __dirname + '/public' })
app.use express.static(path.join(__dirname, 'public'))


app.get '/', routes.index
app.get '/users', user.list

app.get '/stats', (req, res) ->
async.parallel({
Expand Down Expand Up @@ -58,6 +50,15 @@ app.get '/api/voices/', (req, res) ->
res.sendfile './public/api/voices/index.json'
console.log req.session

app.post '/api/shouts/', (req, res) ->
console.log "BBODY", req.body
console.log "FFILES", req.files
res.status(201).send({
'accepted': true,
'processed': false,
'link': "/api/shouts/1234"
})


http.createServer(app).listen app.get('port'), ->
console.log "Express server listening on port " + app.get('port')
1 change: 1 addition & 0 deletions api_srv/models/redis.coffee
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module.exports = redis = require("redis").createClient()
11 changes: 11 additions & 0 deletions api_srv/models/shout.coffee
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
redis = require './redis'
async = require 'async'

Shout = module.exports = {
upload = (voice_id, email) ->
async.auto({
new_shout_id: (cb) ->
redis.incr("shouts_auto_id", cb)
})

}
6 changes: 4 additions & 2 deletions api_srv/models/user.coffee
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
redis = require("redis").createClient()
redis = require './redis'


User = module.exports = {
register: (email, cb) ->
redis.sadd 'users.all', email, cb
total: (cb) ->
redis.scard 'users.all', cb

shout: (voice_id, shout_id, cb) ->
cb()
}

0 comments on commit 6a619b1

Please sign in to comment.