Skip to content

Commit

Permalink
move logging to utils
Browse files Browse the repository at this point in the history
  • Loading branch information
pokutnik committed Mar 30, 2013
1 parent e8f32e3 commit 41feba7
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
10 changes: 6 additions & 4 deletions api_srv/app.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,13 @@ app.configure ->
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.configure 'development', ->
app.use(express.errorHandler())


app.get '/', routes.index
app.get '/users', user.list
Expand All @@ -35,13 +35,15 @@ app.get '/api/', (req, res) ->
res.send api

app.post '/api/', (req, res) ->
api = utils.loadjson './public/api/index.json'
req.session.email = req.body.email
res.send req.session
res.send api



app.get '/api/voices/', (req, res) ->
res.sendfile './public/api/voices/index.json'
console.log req.session

http.createServer(app).listen app.get('port'), ->
console.log "Express server listening on port " + app.get('port')
5 changes: 5 additions & 0 deletions api_srv/utils.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,9 @@ module.exports = {
loadjson: (path) ->
data = fs.readFileSync path, 'utf8'
JSON.parse(data)

sessionLogging: (req, res, next) ->
console.log '%s %s', req.method, req.url
console.log req.session
next()
}

0 comments on commit 41feba7

Please sign in to comment.