Skip to content

Commit

Permalink
Pruned packages
Browse files Browse the repository at this point in the history
  • Loading branch information
GavinDmello committed Sep 15, 2017
1 parent 9781b9f commit e1abb4b
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 17 deletions.
10 changes: 5 additions & 5 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,23 +14,23 @@ class celer {
}

get(url, handler) {
router.when(url, handler)
router.when(url, 'get', handler)
}

post(url, handler) {
router.when(url, handler)
router.when(url, 'post', handler)
}

put(url, handler) {
router.when(url, handler)
router.when(url, 'put', handler)
}

head(url, handler) {
router.when(url, handler)
router.when(url, 'head', handler)
}

patch(url, handler) {
router.when(url, handler)
router.when(url, 'patch', handler)
}


Expand Down
11 changes: 4 additions & 7 deletions lib/event-router.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
const urlTrim = require('url-trim')
const ResponseWrapper = require('./response')
const responseWrapper = new ResponseWrapper()
const traceback = require('stack-trace')

class EventRouter extends EventEmitter {

Expand All @@ -11,15 +10,13 @@ class EventRouter extends EventEmitter {

send(request, response) {

var sendTo = request.method.toLowerCase() + urlTrim(request.url)
response.send = responseWrapper.send
var sendTo = request.method.toLowerCase() + urlTrim(request.url)
response.send = responseWrapper.send
this.emit(sendTo, request, response)
}

when(url, handler) {

this.trace = traceback.get()[1]
this.on(this.trace.getMethodName() + url, handler)
when(url, method, handler) {
this.on(method + url, handler)
}
}

Expand Down
6 changes: 2 additions & 4 deletions lib/object-router.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ const EventEmitter = require('events')
const urlTrim = require('url-trim')
const ResponseWrapper = require('./response')
const responseWrapper = new ResponseWrapper()
const traceback = require('stack-trace')

class ObjectRouter {

Expand All @@ -19,10 +18,9 @@ class ObjectRouter {
}
}

when(url, handler) {
when(url, method, handler) {

this.trace = traceback.get()[1]
this.routes[this.trace.getMethodName() + url] = handler
this.routes[method + url] = handler

}
}
Expand Down
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
"author": "",
"license": "ISC",
"dependencies": {
"stack-trace": "0.0.9",
"url-trim": "^1.0.0"
}
}

0 comments on commit e1abb4b

Please sign in to comment.