Skip to content

Commit

Permalink
fix: Use micro's send() instead of res directly
Browse files Browse the repository at this point in the history
  • Loading branch information
MiniGod authored and pedronauck committed Jul 18, 2017
1 parent 41e6e0e commit c9fca3a
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
const UrlPattern = require('url-pattern')
const { send } = require('micro')
const { getParamsAndQuery } = require('../utils')

const METHODS = ['GET', 'POST', 'PUT', 'PATCH', 'DELETE', 'HEAD', 'OPTIONS']
Expand All @@ -24,8 +25,7 @@ exports.router = (...funcs) => async (req, res) => {
if (result || res.headersSent) return result
}

res.writeHead(404)
res.end(`Cannot ${req.method} ${req.url}`)
send(res, 404, `Cannot ${req.method} ${req.url}`)
}

METHODS.forEach(method => {
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
"author": "Pedro Nauck <[email protected]>",
"license": "MIT",
"dependencies": {
"micro": "^7.3.3",
"url-pattern": "^1.0.3"
},
"devDependencies": {
Expand Down

0 comments on commit c9fca3a

Please sign in to comment.