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.15.3 to 0.16.0

2

docs/ContentTypeParser.md

@@ -17,1 +17,3 @@ <h1 align="center">Fastify</h1>

```
You can also use the api `hasContentTypeParser` to find if a specific content-type parser already exist.

2

docs/Routes.md

@@ -16,3 +16,3 @@ <h1 align="center">Fastify</h1>

* `payload`: validates the body of the request if it is a POST or a
* `body`: validates the body of the request if it is a POST or a
PUT.

@@ -19,0 +19,0 @@ * `querystring`: validates the querystring. This can be a complete JSON

@@ -86,1 +86,5 @@ <h1 align="center">Fastify</h1>

Function to add a specific hook in the lifecycle of Fastify, check [here](https://github.com/fastify/fastify/blob/master/docs/Hooks.md).
<a name="logger"></a>
#### logger
The logger instance, check [here](https://github.com/fastify/fastify/blob/master/docs/Logging.md).

@@ -11,3 +11,3 @@ <h1 align="center">Fastify</h1>

The supported validations are:
- `payload`: validates the body of the request if it is a POST or a PUT.
- `body`: validates the body of the request if it is a POST or a PUT.
- `querystring`: validates the querystring. This can be a complete JSON Schema object, with the property type of object and properties object of parameters, or simply the values of what would be contained in the properties object as shown below.

@@ -19,3 +19,3 @@ - `params`: validates the route params.

const schema = {
payload: {
body: {
type: 'object',

@@ -22,0 +22,0 @@ properties: {

@@ -39,12 +39,12 @@ 'use strict'

.post('/', schema, function (req, reply) {
reply.send(null, { hello: 'world' })
reply.send({ hello: 'world' })
})
.head('/', {}, function (req, reply) {
reply.send(null)
reply.send()
})
.delete('/', schema, function (req, reply) {
reply.send(null, { hello: 'world' })
reply.send({ hello: 'world' })
})
.patch('/', schema, function (req, reply) {
reply.send(null, { hello: 'world' })
reply.send({ hello: 'world' })
})

@@ -51,0 +51,0 @@

@@ -66,2 +66,5 @@ 'use strict'

// expose logger instance
fastify.logger = logger
// hooks

@@ -311,7 +314,9 @@ fastify.addHook = addHook

function addHook (name, fn) {
return this._hooks.add(name, fn)
this._hooks.add(name, fn)
return this
}
function addContentTypeParser (contentType, fn) {
return this._contentTypeParser.add(contentType, fn)
this._contentTypeParser.add(contentType, fn)
return this
}

@@ -318,0 +323,0 @@

@@ -8,3 +8,3 @@ 'use strict'

const payloadSchema = Symbol('payload-schema')
const bodySchema = Symbol('body-schema')
const querystringSchema = Symbol('querystring-schema')

@@ -29,4 +29,4 @@ const outputSchema = Symbol('output-schema')

if (opts.schema.payload) {
opts[payloadSchema] = ajv.compile(opts.schema.payload)
if (opts.schema.body) {
opts[bodySchema] = ajv.compile(opts.schema.body)
}

@@ -56,4 +56,4 @@

if (handle[payloadSchema] && !handle[payloadSchema](body)) {
return inputSchemaError(handle[payloadSchema].errors)
if (handle[bodySchema] && !handle[bodySchema](body)) {
return inputSchemaError(handle[bodySchema].errors)
}

@@ -84,2 +84,2 @@

module.exports = { build, validate, serialize, isValidLogger }
module.exports.symbols = { payloadSchema, querystringSchema, outputSchema, paramsSchema }
module.exports.symbols = { bodySchema, querystringSchema, outputSchema, paramsSchema }
{
"name": "fastify",
"version": "0.15.3",
"version": "0.16.0",
"description": "Fast and low overhead web framework, for Node.js",

@@ -5,0 +5,0 @@ "main": "fastify.js",

@@ -12,3 +12,3 @@ 'use strict'

const schema = {
payload: {
body: {
type: 'object',

@@ -15,0 +15,0 @@ properties: {

@@ -33,3 +33,3 @@ /* eslint-disable no-useless-return */

schema: {
payload: {
body: {
type: 'object',

@@ -36,0 +36,0 @@ properties: {

@@ -12,3 +12,3 @@ 'use strict'

t.is(typeof symbols.outputSchema, 'symbol')
t.is(typeof symbols.payloadSchema, 'symbol')
t.is(typeof symbols.bodySchema, 'symbol')
t.is(typeof symbols.querystringSchema, 'symbol')

@@ -52,3 +52,3 @@ t.is(typeof symbols.paramsSchema, 'symbol')

schema: {
payload: {
body: {
type: 'object',

@@ -62,3 +62,3 @@ properties: {

validation.build(opts)
t.is(typeof opts[symbols.payloadSchema], 'function')
t.is(typeof opts[symbols.bodySchema], 'function')
})

@@ -65,0 +65,0 @@

@@ -85,1 +85,7 @@ 'use strict'

})
test('expose the logger', t => {
t.plan(2)
t.ok(fastify.logger)
t.is(typeof fastify.logger, 'function')
})
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