Comparing version 0.29.0 to 0.29.1
@@ -128,2 +128,11 @@ <h1 align="center">Fastify</h1> | ||
``` | ||
<a name="slides"></a> | ||
### Slides and Videos | ||
- Slides | ||
- [Take your http server to ludicrous speed](https://mcollina.github.io/take-your-http-server-to-ludicrous-speed) by [@mcollina](https://github.com/mcollina) | ||
- [What if I told you that HTTP can be fast](https://delvedor.github.io/What-if-I-told-you-that-HTTP-can-be-fast) by [@delvedor](https://github.com/delvedor) | ||
- Videos | ||
- [Take your http server to ludicrous speed](https://www.youtube.com/watch?v=5z46jJZNe8k) by [@mcollina](https://github.com/mcollina) | ||
<a name="next"></a> | ||
@@ -130,0 +139,0 @@ ### Next |
@@ -96,7 +96,4 @@ <h1 align="center">Fastify</h1> | ||
### Testing with http injection | ||
Fastify supports fake http injection thanks to [shot](https://github.com/hapijs/shot). | ||
To support this method, you should list `shot` library in your package as dev dependency using | ||
``` | ||
npm install shot@3 --save-dev | ||
``` | ||
Fastify supports fake http injection thanks to [light-my-request](https://github.com/fastify/light-my-request). | ||
You just need to use the api `inject`: | ||
@@ -117,9 +114,9 @@ ```js | ||
```js | ||
const injectOption = { | ||
method: String, | ||
url: String, | ||
payload: Object, | ||
headers: Object | ||
} | ||
fastify.inject(injectOption) | ||
fastify | ||
.inject({ | ||
method: String, | ||
url: String, | ||
payload: Object, | ||
headers: Object | ||
}) | ||
.then(response => { | ||
@@ -130,2 +127,6 @@ // your tests | ||
Async await is supported as well! | ||
```js | ||
const res = await fastify.inject({ method: String, url: String, payload: Object, headers: Object }) | ||
``` | ||
Example: | ||
@@ -132,0 +133,0 @@ ```js |
@@ -84,5 +84,3 @@ <h1 align="center">Fastify</h1> | ||
}, | ||
schemaCompiler: function (schema) { | ||
return schema.validate.bind(validate) | ||
} | ||
schemaCompiler: schema => data => Joi.validate(data, schema) | ||
}) | ||
@@ -89,0 +87,0 @@ ``` |
@@ -229,3 +229,3 @@ | ||
*/ | ||
decorateResponse(name: string, decoration: any, dependencies?: Array<string>): FastifyInstance | ||
decorateRequest(name: string, decoration: any, dependencies?: Array<string>): FastifyInstance | ||
@@ -232,0 +232,0 @@ /** |
@@ -10,6 +10,4 @@ 'use strict' | ||
const runHooks = require('fastseries')() | ||
const lightMyRequest = require('light-my-request') | ||
var shot = null | ||
try { shot = require('shot') } catch (e) { } | ||
const Reply = require('./lib/reply') | ||
@@ -486,15 +484,19 @@ const Request = require('./lib/request') | ||
function inject (opts, cb) { | ||
if (!shot) throw new Error('"shot" library is not installed: "npm install shot@3 --save-dev"') | ||
if (started) { | ||
return lightMyRequest(this, opts, cb) | ||
} | ||
const waitingForReadyEvent = started | ||
? Promise.resolve() | ||
: new Promise((resolve, reject) => this.ready(err => (err ? reject : resolve)(err))) | ||
const injectPromise = waitingForReadyEvent | ||
.then(() => new Promise(resolve => shot.inject(this, opts, resolve))) | ||
if (cb) { | ||
injectPromise.then(cb, cb) | ||
return | ||
this.ready(err => { | ||
if (err) throw err | ||
return lightMyRequest(this, opts, cb) | ||
}) | ||
} else { | ||
return new Promise((resolve, reject) => { | ||
this.ready(err => { | ||
if (err) return reject(err) | ||
resolve() | ||
}) | ||
}).then(() => lightMyRequest(this, opts)) | ||
} | ||
return injectPromise | ||
} | ||
@@ -591,16 +593,6 @@ | ||
var prefix = this._RoutePrefix.prefix | ||
var star = '*' | ||
var star = '/*' | ||
// TODO this would need to be refactored once | ||
// https://github.com/delvedor/find-my-way/issues/28 | ||
// is solved | ||
if (prefix && prefix[prefix.length - 1] !== '/') { | ||
star = '/*' | ||
} else { | ||
fourOhFour.all(prefix + '/', startHooks, store) | ||
fourOhFour.all(prefix + '/*', startHooks, store) | ||
} | ||
fourOhFour.all(prefix + star, startHooks, store) | ||
fourOhFour.all(prefix, startHooks, store) | ||
fourOhFour.all(prefix || '/', startHooks, store) | ||
} else { | ||
@@ -607,0 +599,0 @@ this._404Store.handler = handler |
{ | ||
"name": "fastify", | ||
"version": "0.29.0", | ||
"version": "0.29.1", | ||
"description": "Fast and low overhead web framework, for Node.js", | ||
@@ -68,3 +68,3 @@ "main": "fastify.js", | ||
"cors": "^2.8.4", | ||
"coveralls": "^2.13.1", | ||
"coveralls": "^2.13.3", | ||
"dns-prefetch-control": "^0.1.0", | ||
@@ -75,3 +75,3 @@ "fast-json-body": "^1.1.0", | ||
"frameguard": "^3.0.0", | ||
"helmet": "^3.6.1", | ||
"helmet": "^3.8.2", | ||
"hide-powered-by": "^1.0.0", | ||
@@ -82,5 +82,4 @@ "hsts": "^2.0.0", | ||
"pre-commit": "^1.2.2", | ||
"request": "^2.82.0", | ||
"serve-static": "^1.12.5", | ||
"shot": "^3.4.2", | ||
"request": "^2.83.0", | ||
"serve-static": "^1.13.0", | ||
"snazzy": "^7.0.0", | ||
@@ -91,9 +90,9 @@ "split2": "^2.2.0", | ||
"then-sleep": "^1.0.1", | ||
"typescript": "^2.5.2", | ||
"typescript": "^2.5.3", | ||
"x-xss-protection": "^1.0.0" | ||
}, | ||
"dependencies": { | ||
"@types/node": "^8.0.30", | ||
"@types/node": "^8.0.31", | ||
"@types/pino": "~4.7.0", | ||
"ajv": "^5.2.2", | ||
"ajv": "^5.2.3", | ||
"avvio": "^2.2.0", | ||
@@ -103,4 +102,5 @@ "fast-json-stringify": "^0.13.1", | ||
"fastseries": "^1.7.2", | ||
"find-my-way": "^1.5.0", | ||
"find-my-way": "^1.6.2", | ||
"flatstr": "^1.0.5", | ||
"light-my-request": "^1.0.0", | ||
"middie": "^2.0.0", | ||
@@ -107,0 +107,0 @@ "pino": "^4.7.2", |
@@ -113,2 +113,6 @@ <div align="center"> | ||
Multipart support for Fastify | ||
- [`fastify-nats`](https://github.com/mahmed8003/fastify-nats) | ||
Plugin to share [NATS](http://nats.io) client across Fastify. | ||
- [`fastify-orientdb`](https://github.com/mahmed8003/fastify-orientdb) | ||
Fastify OrientDB connection plugin, with this you can share the orientdb connection in every part of your server. | ||
- [`fastify-pigeon`](https://github.com/fastify/fastify-pigeon) [Bankai](https://github.com/yoshuawuyts/bankai) assets compiler for Fastify | ||
@@ -125,4 +129,2 @@ - [`fastify-react`](https://github.com/fastify/fastify-react) React server side rendering support for Fastify with [Next](https://github.com/zeit/next.js/) | ||
Templates rendering (*ejs, pug, handlebars, marko*) plugin support for Fastify. | ||
- [`fastify-orientdb`](https://github.com/mahmed8003/fastify-orientdb) | ||
Fastify OrientDB connection plugin, with this you can share the orientdb connection in every part of your server. | ||
- *More coming soon* | ||
@@ -129,0 +131,0 @@ |
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
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
Network access
Supply chain riskThis module accesses the network.
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
302313
25
94
7958
157
13
6
8
+ Addedlight-my-request@^1.0.0
+ Addedlight-my-request@1.1.2(transitive)
+ Addedsafe-buffer@5.2.1(transitive)
Updated@types/node@^8.0.31
Updatedajv@^5.2.3
Updatedfind-my-way@^1.6.2