Comparing version 0.1.0 to 0.2.0
@@ -7,2 +7,3 @@ 'use strict' | ||
const jsonParser = require('body/json') | ||
const pluginLoader = require('boot-in-the-arse') | ||
@@ -18,2 +19,3 @@ const supportedMethods = ['GET', 'POST', 'PUT'] | ||
const map = new Map() | ||
pluginLoader(fastify, {}) | ||
router.on('/404', defaultRoute) | ||
@@ -27,2 +29,4 @@ | ||
fastify.route = route | ||
// plugin | ||
fastify.register = fastify.use | ||
@@ -29,0 +33,0 @@ return fastify |
{ | ||
"name": "fastify", | ||
"version": "0.1.0", | ||
"version": "0.2.0", | ||
"description": "Fast and low overhead web framework, for Node.js", | ||
@@ -42,2 +42,3 @@ "main": "fastify.js", | ||
"body": "^5.1.0", | ||
"boot-in-the-arse": "^0.3.0", | ||
"fast-json-stringify": "^0.10.0", | ||
@@ -44,0 +45,0 @@ "fast-safe-stringify": "^1.1.0", |
@@ -84,3 +84,3 @@ # Fastify [![Build Status](https://travis-ci.org/mcollina/fastify.svg)](https://travis-ci.org/mcollina/fastify) [![Coverage Status](https://coveralls.io/repos/github/mcollina/fastify/badge.svg?branch=master)](https://coveralls.io/github/mcollina/fastify?branch=master) | ||
* <a href="#put"><code>fastify.<b>put()</b></code></a> | ||
* <a href="#request"><code>fastify.<b>Request</b></code></a> | ||
* <a href="#register"><code>fastify.<b>register()</b></code></a> | ||
@@ -133,2 +133,12 @@ <a name="constructor"></a> | ||
<a name="request"></a> | ||
#### Request | ||
An object including the following properties: | ||
* `query` - the parsed querystring | ||
* `body` - the body | ||
* `params` - the params matching the URL | ||
* `req` - the incoming HTTP request from Node core | ||
<a name="get"></a> | ||
@@ -152,12 +162,48 @@ ### fastify.get(path, [schema], handler) | ||
<a name="request"></a> | ||
### Request | ||
<a name="register"></a> | ||
### fastify.register(plugin, [options], [callback]) | ||
Used to register one or more plugins. | ||
`plugin` can be a single function or an array of functions. | ||
In case of the array of functions, the same options object and callback will be passed to them. | ||
[boot-in-the-arse](https://github.com/mcollina/boot-in-the-arse) is used to load the plugins. | ||
Example: | ||
```js | ||
// server.js | ||
const fastify = require('fastify')() | ||
const http = require('http') | ||
const server = http.createServer(fastify) | ||
An object including the following properties: | ||
fastify.register(require('./plugin'), function (err) { | ||
if (err) throw err | ||
}) | ||
* `query` - the parsed querystring | ||
* `body` - the body | ||
* `params` - the params matching the URL | ||
* `req` - the incoming HTTP request from Node core | ||
const opts = { | ||
hello: 'world', | ||
something: true | ||
} | ||
fastify.register([ | ||
require('./another-plugin') | ||
require('./yet-another-plugin') | ||
], opts, function (err) { | ||
if (err) throw err | ||
}) | ||
server.listen(8000, function (err) { | ||
if (err) { | ||
throw err | ||
} | ||
console.log(`server listening on ${server.address().port}`) | ||
}) | ||
``` | ||
```js | ||
// plugin.js | ||
module.exports = function (fastify, options, next) { | ||
fastify.get('/', schema, function (req, reply) { | ||
reply(null, { hello: 'world' }) | ||
}) | ||
next() | ||
} | ||
``` | ||
<a name="team"></a> | ||
@@ -164,0 +210,0 @@ ## The Team |
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
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
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
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
32277
25
940
241
7
8
+ Addedboot-in-the-arse@^0.3.0
+ Addedboot-in-the-arse@0.3.0(transitive)
+ Addedfastq@1.17.1(transitive)
+ Addedreusify@1.0.4(transitive)