Socket
Socket
Sign inDemoInstall

fastify

Package Overview
Dependencies
Maintainers
2
Versions
288
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

fastify - npm Package Compare versions

Comparing version 0.1.0 to 0.2.0

plugin.js

4

fastify.js

@@ -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

3

package.json
{
"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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc