Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

fastify-plugin

Package Overview
Dependencies
Maintainers
3
Versions
43
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

fastify-plugin - npm Package Compare versions

Comparing version 0.1.0 to 0.1.1

11

index.js
'use strict'
const semver = require('semver')
const console = require('console')

@@ -15,4 +16,10 @@ function plugin (fn, version) {

const fastifyVersion = require('fastify/package.json').version
if (!semver.satisfies(fastifyVersion, version)) {
var fastifyVersion
try {
fastifyVersion = require('fastify/package.json').version
} catch (_) {
console.info('fastify not found, proceeding anyway')
}
if (fastifyVersion && !semver.satisfies(fastifyVersion, version)) {
throw new Error(`fastify-plugin - expected '${version}' fastify version, '${fastifyVersion}' is installed`)

@@ -19,0 +26,0 @@ }

7

package.json
{
"name": "fastify-plugin",
"version": "0.1.0",
"version": "0.1.1",
"description": "Plugin helper for Fastify",

@@ -25,4 +25,5 @@ "main": "index.js",

"devDependencies": {
"fastify": "^0.12.0",
"standard": "^9.0.2",
"fastify": "^0.18.0",
"proxyquire": "^1.8.0",
"standard": "^10.0.0",
"tap": "^10.3.0"

@@ -29,0 +30,0 @@ },

# fastify-plugin
[![js-standard-style](https://img.shields.io/badge/code%20style-standard-brightgreen.svg?style=flat)](http://standardjs.com/)

@@ -6,3 +7,3 @@ [![Build Status](https://travis-ci.org/fastify/fastify-plugin.svg?branch=master)](https://travis-ci.org/fastify/fastify-plugin)

`fastify-plugin` is a plugin helper for [Fastify](https://github.com/fastify/fastify).
When you build plugins for Fastify and you want that them to be accessible in the same contewxt where you require them, you have two ways:
When you build plugins for Fastify and you want that them to be accessible in the same context where you require them, you have two ways:
1. Use the `skip-override` hidden property

@@ -9,0 +10,0 @@ 2. Use this module

'use strict'
const t = require('tap')
const proxyquire = require('proxyquire')
const test = t.test

@@ -75,1 +76,20 @@ const fp = require('./')

})
test('should not throw if fastify is not found', t => {
t.plan(1)
const fp = proxyquire('./index.js', {
'fastify/package.json': null,
console: {
info: function (msg) {
t.is(msg, 'fastify not found, proceeding anyway')
}
}
})
function plugin (fastify, opts, next) {
next()
}
fp(plugin, '>= 0')
})

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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