UNPKG

598 Btext/coffeescriptView Raw
1http = require "http"
2url = require "url"
3
4module.exports = class Daemon
5
6 constructor: ({@config})->
7
8 start:->
9 httpd = http.createServer (req, res)->
10 res.writeHead 200, {'Content-Type': 'application/json'}
11 method = req.method.toLowerCase()
12 {query, pathname} = url.parse req.url
13 [module, command, params...] = pathname.split(/\//).filter (item)-> return item
14 # moduleClass = require "./#{module}.coffee"
15 # moduleInstance = new moduleClass
16 # moduleInstance[command]
17 res.end JSON.stringify {module, command, params, query}
18 httpd.listen 9898
\No newline at end of file