fastify
Advanced tools
Comparing version 0.11.0 to 0.11.1
<h1 align="center">Fastify</h1> | ||
## Getting Started | ||
### Install | ||
``` | ||
npm i fastify --save | ||
``` | ||
### Your first server | ||
Let's write a *Hello world* server! | ||
@@ -5,0 +11,0 @@ ```js |
@@ -43,3 +43,3 @@ /* eslint-disable no-useless-return */ | ||
if (req.headers['content-type']) { | ||
if (req.headers['content-type'] === 'application/json') { | ||
if (req.headers['content-type'].indexOf('application/json') > -1) { | ||
return jsonParser(req, bodyParsed(hooks, handle, params, req, res)) | ||
@@ -56,3 +56,3 @@ } | ||
if (req.method === 'POST' || req.method === 'PUT' || req.method === 'PATCH') { | ||
if (req.headers['content-type'] && req.headers['content-type'] === 'application/json') { | ||
if (req.headers['content-type'] && req.headers['content-type'].indexOf('application/json') > -1) { | ||
return jsonParser(req, bodyParsed(hooks, handle, params, req, res)) | ||
@@ -59,0 +59,0 @@ } |
{ | ||
"name": "fastify", | ||
"version": "0.11.0", | ||
"version": "0.11.1", | ||
"description": "Fast and low overhead web framework, for Node.js", | ||
@@ -5,0 +5,0 @@ "main": "fastify.js", |
@@ -8,3 +8,3 @@ <div align="center"> | ||
[![Build Status](https://travis-ci.org/fastify/fastify.svg?branch=master)](https://travis-ci.org/fastify/fastify) | ||
[![Coverage Status](https://coveralls.io/repos/github/mcollina/fastify/badge.svg?branch=master)](https://coveralls.io/github/mcollina/fastify?branch=master) | ||
[![Coverage Status](https://coveralls.io/repos/github/fastify/fastify/badge.svg?branch=master)](https://coveralls.io/github/mcollina/fastify?branch=master) | ||
[![js-standard-style](https://img.shields.io/badge/code%20style-standard-brightgreen.svg?style=flat)](http://standardjs.com/) | ||
@@ -11,0 +11,0 @@ [![NPM version](https://img.shields.io/npm/v/fastify.svg?style=flat)](https://www.npmjs.com/package/fastify) |
@@ -69,2 +69,18 @@ 'use strict' | ||
test(`${upMethod} - correctly replies if the content type has the charset`, t => { | ||
t.plan(3) | ||
request({ | ||
method: upMethod, | ||
uri: 'http://localhost:' + fastify.server.address().port, | ||
body: JSON.stringify({ hello: 'world' }), | ||
headers: { | ||
'content-type': 'application/json;charset=utf-8' | ||
} | ||
}, (err, response, body) => { | ||
t.error(err) | ||
t.strictEqual(response.statusCode, 200) | ||
t.deepEqual(body, JSON.stringify({ hello: 'world' })) | ||
}) | ||
}) | ||
test(`${upMethod} without schema - correctly replies`, t => { | ||
@@ -71,0 +87,0 @@ t.plan(3) |
103126
2811