New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

fastify-accepts

Package Overview
Dependencies
Maintainers
8
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

fastify-accepts - npm Package Compare versions

Comparing version 1.0.0 to 2.0.0

.dependabot/config.yml

18

index.d.ts
import { Accepts } from "accepts"
import * as fastify from "fastify"
import { Server, IncomingMessage, ServerResponse } from "http"
import { FastifyPlugin } from "fastify"
declare module "fastify" {
interface FastifyRequest<HttpRequest> extends Accepts {
interface FastifyRequestInterface extends Accepts {
accepts(): Accepts
}
interface FastifyReply<HttpResponse> {
interface FastifyReplyInterface {
requestAccepts(): Accepts

@@ -23,9 +22,8 @@ requestCharset: Accepts["charset"]

export const fastifyAccepts: fastify.Plugin<
Server,
IncomingMessage,
ServerResponse,
{}
>
export interface FastifyAcceptsOptions {
decorateReply: boolean
}
declare const fastifyAccepts: FastifyPlugin<FastifyAcceptsOptions>
export default fastifyAccepts

@@ -17,6 +17,6 @@ 'use strict'

function acceptsMethod () {
if (!this.req[acceptsObjectSymbol]) {
this.req[acceptsObjectSymbol] = accepts(this.req)
if (!this.raw[acceptsObjectSymbol]) {
this.raw[acceptsObjectSymbol] = accepts(this.raw)
}
return this.req[acceptsObjectSymbol]
return this.raw[acceptsObjectSymbol]
}

@@ -26,3 +26,3 @@

if (!this.request[acceptsObjectSymbol]) {
this.request[acceptsObjectSymbol] = accepts(this.request.req)
this.request[acceptsObjectSymbol] = accepts(this.request.raw)
}

@@ -33,3 +33,2 @@ return this.request[acceptsObjectSymbol]

function fastifyAcceptHeader (fastify, options, done) {
options = options || {}
const decorateReplyToo = options.decorateReply

@@ -64,4 +63,4 @@

module.exports = fp(fastifyAcceptHeader, {
fastify: '>= 0.39.1',
fastify: '3.x',
name: 'fastify-accepts'
})
{
"name": "fastify-accepts",
"version": "1.0.0",
"version": "2.0.0",
"description": "Add accept parser to fastify",

@@ -9,4 +9,3 @@ "main": "index.js",

"@types/node": "^13.1.8",
"coveralls": "^3.0.0",
"fastify": "^2.0.0",
"fastify": "^3.0.0-rc.1",
"pre-commit": "^1.2.2",

@@ -16,19 +15,18 @@ "request": "^2.88.0",

"standard": "^14.0.2",
"tap": "^12.6.5",
"typescript": "^3.7.5"
"tap": "^14.10.7",
"typescript": "^3.7.5",
"tsd": "^0.11.0"
},
"engines": {
"node": ">=6"
"node": ">=10"
},
"dependencies": {
"accepts": "^1.3.5",
"fastify-plugin": "^1.2.0"
"fastify-plugin": "^2.0.0"
},
"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": "tsc --project ./tsconfig.json"
"typescript": "tsd"
},

@@ -44,8 +42,3 @@ "repository": {

},
"homepage": "https://github.com/fastify/fastify-accepts#readme",
"greenkeeper": {
"ignore": [
"tap"
]
}
"homepage": "https://github.com/fastify/fastify-accepts#readme"
}
# fastify-accepts
[![Greenkeeper badge](https://badges.greenkeeper.io/fastify/fastify-accepts.svg)](https://greenkeeper.io/)
[![Build Status](https://travis-ci.org/fastify/fastify-accepts.svg?branch=master)](https://travis-ci.org/fastify/fastify-accepts)
![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)

@@ -8,0 +6,0 @@

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

t.tearDown(fastify.close.bind(fastify))
fastify.get('/request', function (req, reply) {

@@ -137,4 +139,19 @@ reply.send({

})
})
fastify.server.unref()
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'
]
for (const method of methodNames) {
t.is(fastify.hasReplyDecorator('request' + method, false), false)
}
})
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