-
Notifications
You must be signed in to change notification settings - Fork 3
/
index.js
30 lines (27 loc) · 835 Bytes
/
index.js
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
var dotenv = require('dotenv')
var http = require('http')
var stack = require('stack')
var routes = require('./routes')
var route = require('tiny-route')
var debug = require('debug')('index.js')
if (!module.parent) {
start()
} else {
module.exports = start
}
function start (configPath) {
configPath = configPath || process.env.CONFIG || '.env'
dotenv.load({ path: configPath })
http.createServer(stack(
routes.authenticate,
route.get(/^\/play\/(.*)/, routes.play),
route.get(/^\/stream\/(.*)/, routes.stream),
route.get('/favicon.ico', routes.emptyFavicon),
route.get('/app.css', routes.appCss),
route.post('/search', routes.search),
route.get('/', routes.main)
)).listen(process.env.PORT, started)
function started () {
debug('running on http://localhost:%s', process.env.PORT)
}
}