generated from nirlanka/coffee-site
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserver.coffee
29 lines (22 loc) · 821 Bytes
/
server.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
fs = require "fs"
express = require "express"
app = express()
# Accept JSON as req.body
bodyParser = require "body-parser"
app.use(bodyParser.urlencoded({ extended: false }))
app.use(bodyParser.json())
# CORS - Allow pages from any domain to make requests to our API
app.use (req, res, next) ->
res.header("Access-Control-Allow-Origin", "*")
res.header("Access-Control-Allow-Headers", "Origin, X-Requested-With, Content-Type, Accept")
next()
# Log all requests for diagnostics
app.use (req, res, next) ->
console.log(req.method, req.path, req.body)
next()
# Serve Static files from public/
app.use express.static('public')
(require './torrent-store')(app)
# Listen on App port
listener = app.listen process.env.PORT or 3001, ->
console.log('Your app is listening on port ' + listener.address().port)