diff --git a/.taprc b/.taprc new file mode 100644 index 0000000..43f9ae2 --- /dev/null +++ b/.taprc @@ -0,0 +1,4 @@ +esm: false +ts: false +jsx: false +flow: false diff --git a/README.md b/README.md index 29e974b..1fbf602 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,6 @@ ![CI workflow](https://github.com/fastify/fastify-accepts/workflows/CI%20workflow/badge.svg) [![JavaScript Style Guide](https://img.shields.io/badge/code_style-standard-brightgreen.svg)](https://standardjs.com) -[![Coverage Status](https://coveralls.io/repos/github/fastify/fastify-accepts/badge.svg?branch=feature%2Fshortcuts)](https://coveralls.io/github/fastify/fastify-accepts?branch=feature%2Fshortcuts) [![Known Vulnerabilities](https://snyk.io/test/github/fastify/fastify-accepts/badge.svg)](https://snyk.io/test/github/fastify/fastify-accepts) Add accepts parser to fastify diff --git a/index.js b/index.js index 7ff806d..e263caf 100644 --- a/index.js +++ b/index.js @@ -28,7 +28,6 @@ function replyAcceptMethod () { } function fastifyAcceptHeader (fastify, options, done) { - options = options || {} const decorateReplyToo = options.decorateReply fastify.decorateRequest('accepts', acceptsMethod) @@ -58,6 +57,6 @@ function fastifyAcceptHeader (fastify, options, done) { } module.exports = fp(fastifyAcceptHeader, { - fastify: '>=3', + fastify: '3.x', name: 'fastify-accepts' }) diff --git a/package.json b/package.json index 1cf9bed..22aa54b 100644 --- a/package.json +++ b/package.json @@ -6,7 +6,6 @@ "devDependencies": { "@types/accepts": "^1.3.5", "@types/node": "^13.1.8", - "coveralls": "^3.0.0", "fastify": "^3.0.0-rc.1", "pre-commit": "^1.2.2", "request": "^2.88.0", @@ -25,10 +24,8 @@ }, "scripts": { "lint": "standard | snazzy", - "unit": "tap test.js", + "unit": "tap --100 test.js", "test": "npm run lint && npm run unit && npm run typescript", - "coverage": "tap test.js --cov --coverage-report=text-lcov --coverage-report=html", - "coveralls": "tap test.js --cov --coverage-report=text-lcov | coveralls", "typescript": "tsd" }, "repository": { diff --git a/test.js b/test.js index c118748..7333923 100644 --- a/test.js +++ b/test.js @@ -95,6 +95,8 @@ test('accept header', t => { const fastify = Fastify() fastify.register(plugin, { decorateReply: true }) + t.tearDown(fastify.close.bind(fastify)) + fastify.get('/request', function (req, reply) { reply.send({ types: req.types(), @@ -133,6 +135,21 @@ test('accept header', t => { }) }) }) +}) + +test('no reply decorator', async function (t) { + const fastify = Fastify() + fastify.register(plugin, { decorateReply: false }) + await fastify.ready() + + const methodNames = [ + 'Charset', 'Charsets', + 'Encoding', 'Encodings', + 'Language', 'Languages', + 'Type', 'Types' + ] - fastify.server.unref() + for (const method of methodNames) { + t.is(fastify.hasReplyDecorator('request' + method, false), false) + } })