Socket
Socket
Sign inDemoInstall

fastify

Package Overview
Dependencies
123
Maintainers
2
Versions
282
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.26.1 to 0.26.2

tools/website.sh

2

lib/ContentTypeParser.js

@@ -21,2 +21,4 @@ 'use strict'

ContentTypeParser.prototype.fastHasHeader = function (contentType) {
if (!contentType) return false
for (var i = 0; i < this.parserList.length; i++) {

@@ -23,0 +25,0 @@ if (contentType.indexOf(this.parserList[i]) > -1) return true

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

const stringify = JSON.stringify
const flatstr = require('flatstr')

@@ -93,2 +94,5 @@ function Reply (req, res, store) {

const str = this._serializer ? this._serializer(payload) : serialize(this.store, payload, this.res.statusCode)
if (typeof str === 'string') {
flatstr(str)
}
if (!this.res.getHeader('Content-Length')) {

@@ -95,0 +99,0 @@ this.res.setHeader('Content-Length', Buffer.byteLength(str))

5

package.json
{
"name": "fastify",
"version": "0.26.1",
"version": "0.26.2",
"description": "Fast and low overhead web framework, for Node.js",

@@ -12,3 +12,3 @@ "main": "fastify.js",

"coverage": "tap --cov --coverage-report=html test/*.test.js test/*/*.test.js",
"coveralls": "tap test/*test.js test/*/*.test.js --cov --coverage-report=text-lcov | coveralls",
"coveralls": "tap test/*test.js test/*/*.test.js --cov",
"benchmark": "node ./examples/$npm_config_usingfile & pid=$! && autocannon -c 100 -d 5 -p 10 localhost:3000/ && kill -9 $pid"

@@ -82,2 +82,3 @@ },

"find-my-way": "^1.3.2",
"flatstr": "^1.0.5",
"middie": "^1.0.0",

@@ -84,0 +85,0 @@ "pino-http": "^2.6.1",

@@ -21,2 +21,28 @@ <div align="center">

### Install
```
npm i fastify --save
```
### Example
```js
// Require the framework and instantiate it
const fastify = require('fastify')()
// Declare a route
fastify.get('/', function (request, reply) {
reply.send({ hello: 'world' })
})
// Run the server!
fastify.listen(3000, function (err) {
if (err) throw err
console.log(`server listening on ${fastify.server.address().port}`)
})
```
Do you want to know more? Head to the <a href="https://github.com/fastify/fastify/blob/master/docs/Getting-Started.md"><code><b>Getting Started</b></code></a>.
### Core features

@@ -23,0 +49,0 @@

@@ -195,1 +195,34 @@ 'use strict'

})
test('contentTypeParser shouldn\'t support request with undefined "Content-Type"', t => {
t.plan(3)
const fastify = Fastify()
fastify.post('/', (req, reply) => {
reply.send(req.body)
})
fastify.addContentTypeParser('application/jsoff', function (req, done) {
jsonParser(req, function (err, body) {
if (err) return done(err)
done(body)
})
})
fastify.listen(0, err => {
t.error(err)
request({
method: 'POST',
uri: 'http://localhost:' + fastify.server.address().port,
body: 'unknown content type!',
headers: {
// 'Content-Type': undefined
}
}, (err, response, body) => {
t.error(err)
t.strictEqual(response.statusCode, 415)
fastify.close()
})
})
})
'use strict'
const test = require('tap').test
const fastify = require('..')()
const Fastify = require('..')
const fastify = Fastify()

@@ -23,1 +24,14 @@ test('listen accepts a port and a callback', t => {

})
test('listen after Promise.resolve()', t => {
t.plan(2)
const f = Fastify()
Promise.resolve()
.then(() => {
f.listen(0, (err) => {
f.server.unref()
t.error(err)
t.pass()
})
})
})

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc