Skip to content

Instantly share code, notes, and snippets.

@davidwallacejackson
Created August 2, 2013 03:55
Show Gist options
  • Select an option

  • Save davidwallacejackson/6137382 to your computer and use it in GitHub Desktop.

Select an option

Save davidwallacejackson/6137382 to your computer and use it in GitHub Desktop.
Connection = require('./irc/connection').Connection
exports.load_irc = (req, res, next) ->
if req.params.connection?
connection_name = decodeURIComponent(req.params.connection)
req.connection = Connection.all_connections[connection_name] ? null
if req.connection is null
res.send(404, 'Connection #{connection_name} could not be found.')
if req.params.channel?
channel_name = decodeURIComponent(req.params.channel)
req.channel = req.connection.channels[channel_name] ? null
if req.channel is null
res.send(404, 'Channel #{channel_name} could not be found.')
console.log('woo')
next()
express = require('express')
routes = require('./routes')
http = require('http')
path = require('path')
middleware = require('./middleware')
api = routes.api
console.log(middleware.load_irc)
app = express()
#all environments
app.set('port', process.env.PORT || 3000)
app.set('views', __dirname + '/views')
app.set('view engine', 'jade')
app.use(express.favicon())
app.use(express.logger('dev'))
app.use(express.bodyParser())
app.use(express.methodOverride())
app.use(app.router)
app.use(require('less-middleware')({ src: __dirname + '/public' }))
app.use('/static', express.static(path.join(__dirname, 'public')))
app.use('/bower_components',
express.static(path.join(__dirname, 'bower_components')))
app.use(middleware.load_irc)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment