Comparing version 0.16.0 to 0.17.0
@@ -30,3 +30,3 @@ <h1 align="center">Fastify</h1> | ||
The routing is handled by [wayfarer](https://github.com/yoshuawuyts/wayfarer), so you can refer its documentation for the url building. | ||
The routing is handled by [find-my-way](https://github.com/delvedor/find-my-way), so you can refer its documentation for the url building. | ||
@@ -33,0 +33,0 @@ Example: |
'use strict' | ||
const wayfarer = require('wayfarer') | ||
const stripUrl = require('pathname-match') | ||
const FindMyWay = require('find-my-way') | ||
const avvio = require('avvio') | ||
@@ -16,3 +15,3 @@ const http = require('http') | ||
const buildSchema = require('./lib/validation').build | ||
const buildNode = require('./lib/tier-node') | ||
const handleRequest = require('./lib/handleRequest') | ||
const isValidLogger = require('./lib/validation').isValidLogger | ||
@@ -31,3 +30,3 @@ const decorator = require('./lib/decorate') | ||
if (options.logger && isValidLogger(options.logger)) { | ||
logger = pinoHttp({logger: options.logger}) | ||
logger = pinoHttp({ logger: options.logger }) | ||
} else { | ||
@@ -39,3 +38,3 @@ options.logger = options.logger || {} | ||
const router = wayfarer('/404') | ||
const router = FindMyWay({ defaultRoute: defaultRoute }) | ||
const middie = Middie(_runMiddlewares) | ||
@@ -49,3 +48,2 @@ const run = middie.run | ||
app.override = override | ||
router.on('/404', defaultRoute) | ||
@@ -160,3 +158,3 @@ var server | ||
router(stripUrl(this.req.url), this.req, this.res, this.req.method) | ||
router.lookup(this.req, this.res) | ||
} | ||
@@ -269,12 +267,15 @@ | ||
const url = opts.url || opts.path | ||
if (map.has(url)) { | ||
if (map.get(url)[opts.method]) { | ||
throw new Error(`${opts.method} already set for ${opts.url}`) | ||
throw new Error(`${opts.method} already set for ${url}`) | ||
} | ||
map.get(url)[opts.method] = opts | ||
router.on(opts.method, url, handleRequest, opts) | ||
} else { | ||
const node = buildNode(url, router) | ||
const node = {} | ||
node[opts.method] = opts | ||
map.set(url, node) | ||
router.on(opts.method, url, handleRequest, opts) | ||
} | ||
@@ -358,3 +359,3 @@ | ||
function defaultRoute (params, req, res) { | ||
function defaultRoute (req, res, params) { | ||
res.statusCode = 404 | ||
@@ -361,0 +362,0 @@ res.end() |
{ | ||
"name": "fastify", | ||
"version": "0.16.0", | ||
"version": "0.17.0", | ||
"description": "Fast and low overhead web framework, for Node.js", | ||
@@ -67,4 +67,4 @@ "main": "fastify.js", | ||
"fastseries": "^1.7.2", | ||
"find-my-way": "^0.2.0", | ||
"middie": "^0.2.0", | ||
"pathname-match": "^1.2.0", | ||
"pino-http": "^2.4.2", | ||
@@ -71,0 +71,0 @@ "pump": "^1.0.2", |
@@ -35,3 +35,3 @@ <div align="center"> | ||
- Koa: 9640 req/sec | ||
- **Fastify: 20256 req/sec** | ||
- **Fastify: 21287 req/sec** | ||
@@ -38,0 +38,0 @@ ## Documentation |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
156014
4158
7
+ Addedfind-my-way@^0.2.0
+ Addedfind-my-way@0.2.4(transitive)
- Removedpathname-match@^1.2.0