-
Notifications
You must be signed in to change notification settings - Fork 3
/
tastebin.coffee
executable file
·36 lines (30 loc) · 1.01 KB
/
tastebin.coffee
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#!/usr/bin/env coffee
debug = require('debug') 'tastebin'
express = require 'express'
mustacheExpress = require 'mustache-express'
config = require './config'
router = require('./index') config
for serverConfig in config.listenOn
app = express()
app.engine 'mustache', mustacheExpress()
app.set 'view engine', 'mustache'
app.set 'view cache', false
app.set 'x-powered-by', false
app.set 'views', "#{__dirname}/static"
app.set 'strict routing', true
if serverConfig.headers?
app.use (req, res, next) ->
res.set serverConfig.headers
next()
app.use config.subpath, router
module = require serverConfig.module
if serverConfig.options?
server = module.createServer serverConfig.options, app
else
server = module.createServer app
port = process.env.PORT
port ?= serverConfig.port
server.listen port, serverConfig.hostname, () ->
address = server.address().address
port = server.address().port
debug "Server listening on #{serverConfig.protocol}://#{address}:#{port}"