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

mercurius-upload

Package Overview
Dependencies
Maintainers
2
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mercurius-upload - npm Package Compare versions

Comparing version 4.0.0 to 5.0.0

7

dist/index.d.ts
/// <reference types="node" />
import { UploadOptions } from 'graphql-upload'
import processRequest from 'graphql-upload/processRequest.js'
import type { FastifyPluginCallback } from 'fastify'

@@ -10,5 +10,6 @@ declare module 'fastify' {

export declare const mercuriusUpload: FastifyPluginCallback<
UploadOptions,
import('http').Server
processRequest.ProcessRequestOptions,
import('http').Server,
import('fastify').FastifyTypeProviderDefault
>
export default mercuriusUpload

@@ -10,3 +10,5 @@ 'use strict'

const fastify_plugin_1 = __importDefault(require('fastify-plugin'))
const graphql_upload_1 = require('graphql-upload')
const processRequest_js_1 = __importDefault(
require('graphql-upload/processRequest.js')
)
const mercuriusGQLUpload = (fastify, options, done) => {

@@ -21,3 +23,3 @@ fastify.addContentTypeParser('multipart', (req, _payload, done) => {

}
request.body = await (0, graphql_upload_1.processRequest)(
request.body = await (0, processRequest_js_1.default)(
request.raw,

@@ -24,0 +26,0 @@ reply.raw,

{
"name": "mercurius-upload",
"version": "4.0.0",
"version": "5.0.0",
"description": "Fastify plugin to support GraphQL uploads using graphql-upload",

@@ -31,26 +31,24 @@ "keywords": [

"dependencies": {
"@types/graphql-upload": "^8.0.7",
"fastify-plugin": "^3.0.0",
"graphql-upload": "^13.0.0"
"fastify-plugin": "^3.0.1",
"graphql-upload": "^15.0.1"
},
"devDependencies": {
"@types/node": "^16.11.12",
"@types/tap": "^15.0.5",
"@types/node": "^16.11.39",
"@types/tap": "^15.0.7",
"cross-env": "^7.0.3",
"fastify": "^3.24.1",
"fastify": "^4.0.1",
"form-data": "^4.0.0",
"graphql": "^15.8.0",
"mercurius": "^8.11.2",
"prettier": "^2.5.1",
"tap": "^15.1.5",
"ts-node": "^10.4.0",
"typescript": "^4.5.3"
"graphql": "^16.5.0",
"mercurius": "^10.0.0",
"prettier": "^2.6.2",
"tap": "^16.2.0",
"ts-node": "^10.8.1",
"typescript": "^4.7.3"
},
"peerDependencies": {
"graphql": "0.13.1 - 16"
"graphql": "^16.3.0"
},
"scripts": {
"test": "tap --ts --100 test/*.test.ts"
},
"readme": "# mercurius-upload\n\n[graphql-upload](https://github.com/jaydenseric/graphql-upload) implementation plugin for [Fastify](https://www.fastify.io/) & [mercurius](https://github.com/mercurius-js/mercurius).\n\nPlugin made for **Fastify v3**:\n\n## Install\n\n```sh\nyarn add mercurius-upload\n# or\nnpm i mercurius-upload\n# or\npnpm add mercurius-upload\n```\n\n## Usage\n\nPlugin options should conform to https://github.com/jaydenseric/graphql-upload#type-processrequestoptions\n\n```js\nfastify.register(require('mercurius-upload'), {\n // options passed to processRequest from graphql-upload\n})\n```\n\n> or\n\n```ts\nimport MercuriusGQLUpload from 'mercurius-upload'\n\n// ...\n\nfastify.register(MercuriusGQLUpload, {\n // options passed to processRequest from graphql-upload\n})\n```\n\n## Example\n\n```js\nconst GQL = require('mercurius')\nconst { GraphQLUpload } = require('graphql-upload')\nconst fs = require('fs')\nconst util = require('util')\nconst stream = require('stream')\nconst path = require('path')\n\nconst pipeline = util.promisify(stream.pipeline)\nconst uploadsDir = path.resolve(__dirname, '../uploads')\n\nconst schema = /* GraphQL */ `\n scalar Upload\n\n type Query {\n add(x: Int, y: Int): Int\n }\n\n type Mutation {\n uploadImage(image: Upload): Boolean\n }\n`\n\nconst resolvers = {\n Upload: GraphQLUpload,\n Query: {\n add: async (_, { x, y }) => {\n return x + y\n },\n },\n Mutation: {\n uploadImage: async (_, { image }) => {\n const { filename, createReadStream } = await image\n const rs = createReadStream()\n const ws = fs.createWriteStream(path.join(uploadsDir, filename))\n await pipeline(rs, ws)\n return true\n },\n },\n}\n\nmodule.exports = function (fastify, options, done) {\n fastify.register(require('mercurius-upload'))\n\n fastify.register(GQL, {\n schema,\n resolvers,\n graphiql: true,\n })\n\n done()\n}\n```\n"
}
}
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