Skip to content

Commit

Permalink
Wrote some unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
dhershman1 committed Jan 9, 2020
1 parent 7704294 commit ffa197d
Show file tree
Hide file tree
Showing 9 changed files with 729 additions and 167 deletions.
12 changes: 10 additions & 2 deletions lib/router/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const _curryOpt = require('../_internals/_curryOpt')
* TODO: This could for sure be improved for both performance, and readability
* @function
* @public
* @param {Map} root The root Branch
* @param {Map[]} root The root Branch
* @param {Array} routes An array of Maps to attach to the root branch
* @returns {Map} A new concated map object
*/
Expand Down Expand Up @@ -108,11 +108,19 @@ function setHeaders (response) {
}
}

/**
* Handles running middleware for the route and method stages, as well as the route response
* @function
* @private
* @param {Object} ctx The route context
* @param {Map} routeMap The Route Map Tree we are looking through
* @returns {Promise}
*/
function handleRoute (ctx, routeMap) {
const routeMw = routeMap.get('middleware')
const { fn, middleware = [] } = routeMap.get('methods').get(ctx.request.method)

pipeP(routeMw, ctx)
return pipeP(routeMw, ctx)
.then(pipeP(middleware))
.then(finalCtx => fn(finalCtx).then(res => res(finalCtx)))
}
Expand Down
Loading

0 comments on commit ffa197d

Please sign in to comment.