graphql-upload 12.0.0 → 15.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/GRAPHQL_MULTIPART_REQUEST_SPEC_URL.js +12 -0
- package/GraphQLUpload.js +80 -0
- package/Upload.js +55 -0
- package/changelog.md +76 -0
- package/graphqlUploadExpress.js +80 -0
- package/graphqlUploadKoa.js +69 -0
- package/ignoreStream.js +17 -0
- package/license.md +9 -0
- package/package.json +51 -40
- package/processRequest.js +427 -0
- package/readme.md +20 -385
- package/private/GRAPHQL_MULTIPART_REQUEST_SPEC_URL.js +0 -12
- package/private/ignoreStream.js +0 -16
- package/public/GraphQLUpload.js +0 -90
- package/public/Upload.js +0 -75
- package/public/graphqlUploadExpress.js +0 -76
- package/public/graphqlUploadKoa.js +0 -69
- package/public/index.js +0 -75
- package/public/index.mjs +0 -5
- package/public/processRequest.js +0 -361
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
// @ts-check
|
|
2
|
+
|
|
3
|
+
"use strict";
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* [GraphQL multipart request spec](https://github.com/jaydenseric/graphql-multipart-request-spec)
|
|
7
|
+
* URL. Useful for error messages, etc.
|
|
8
|
+
*/
|
|
9
|
+
const GRAPHQL_MULTIPART_REQUEST_SPEC_URL =
|
|
10
|
+
"https://github.com/jaydenseric/graphql-multipart-request-spec";
|
|
11
|
+
|
|
12
|
+
module.exports = GRAPHQL_MULTIPART_REQUEST_SPEC_URL;
|
package/GraphQLUpload.js
ADDED
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
// @ts-check
|
|
2
|
+
|
|
3
|
+
"use strict";
|
|
4
|
+
|
|
5
|
+
const { GraphQLScalarType, GraphQLError } = require("graphql");
|
|
6
|
+
const Upload = require("./Upload.js");
|
|
7
|
+
|
|
8
|
+
/** @typedef {import("./processRequest").FileUpload} FileUpload */
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* A GraphQL `Upload` scalar that can be used in a
|
|
12
|
+
* [`GraphQLSchema`](https://graphql.org/graphql-js/type/#graphqlschema). It’s
|
|
13
|
+
* value in resolvers is a promise that resolves
|
|
14
|
+
* {@link FileUpload file upload details} for processing and storage.
|
|
15
|
+
* @example
|
|
16
|
+
* A schema built using
|
|
17
|
+
* [`makeExecutableSchema`](https://www.graphql-tools.com/docs/api/modules/schema_src#makeexecutableschema)
|
|
18
|
+
* from [`@graphql-tools/schema`](https://npm.im/@graphql-tools/schema):
|
|
19
|
+
*
|
|
20
|
+
* ```js
|
|
21
|
+
* const { makeExecutableSchema } = require("@graphql-tools/schema");
|
|
22
|
+
* const GraphQLUpload = require("graphql-upload/GraphQLUpload.js");
|
|
23
|
+
*
|
|
24
|
+
* const schema = makeExecutableSchema({
|
|
25
|
+
* typeDefs: `
|
|
26
|
+
* scalar Upload
|
|
27
|
+
* `,
|
|
28
|
+
* resolvers: {
|
|
29
|
+
* Upload: GraphQLUpload,
|
|
30
|
+
* },
|
|
31
|
+
* });
|
|
32
|
+
* ```
|
|
33
|
+
* @example
|
|
34
|
+
* A manually constructed schema with an image upload mutation:
|
|
35
|
+
*
|
|
36
|
+
* ```js
|
|
37
|
+
* const { GraphQLSchema, GraphQLObjectType, GraphQLBoolean } = require("graphql");
|
|
38
|
+
* const GraphQLUpload = require("graphql-upload/GraphQLUpload.js");
|
|
39
|
+
*
|
|
40
|
+
* const schema = new GraphQLSchema({
|
|
41
|
+
* mutation: new GraphQLObjectType({
|
|
42
|
+
* name: "Mutation",
|
|
43
|
+
* fields: {
|
|
44
|
+
* uploadImage: {
|
|
45
|
+
* description: "Uploads an image.",
|
|
46
|
+
* type: GraphQLBoolean,
|
|
47
|
+
* args: {
|
|
48
|
+
* image: {
|
|
49
|
+
* description: "Image file.",
|
|
50
|
+
* type: GraphQLUpload,
|
|
51
|
+
* },
|
|
52
|
+
* },
|
|
53
|
+
* async resolve(parent, { image }) {
|
|
54
|
+
* const { filename, mimetype, createReadStream } = await image;
|
|
55
|
+
* const stream = createReadStream();
|
|
56
|
+
* // Promisify the stream and store the file, then…
|
|
57
|
+
* return true;
|
|
58
|
+
* },
|
|
59
|
+
* },
|
|
60
|
+
* },
|
|
61
|
+
* }),
|
|
62
|
+
* });
|
|
63
|
+
* ```
|
|
64
|
+
*/
|
|
65
|
+
const GraphQLUpload = new GraphQLScalarType({
|
|
66
|
+
name: "Upload",
|
|
67
|
+
description: "The `Upload` scalar type represents a file upload.",
|
|
68
|
+
parseValue(value) {
|
|
69
|
+
if (value instanceof Upload) return value.promise;
|
|
70
|
+
throw new GraphQLError("Upload value invalid.");
|
|
71
|
+
},
|
|
72
|
+
parseLiteral(node) {
|
|
73
|
+
throw new GraphQLError("Upload literal unsupported.", { nodes: node });
|
|
74
|
+
},
|
|
75
|
+
serialize() {
|
|
76
|
+
throw new GraphQLError("Upload serialization unsupported.");
|
|
77
|
+
},
|
|
78
|
+
});
|
|
79
|
+
|
|
80
|
+
module.exports = GraphQLUpload;
|
package/Upload.js
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
// @ts-check
|
|
2
|
+
|
|
3
|
+
"use strict";
|
|
4
|
+
|
|
5
|
+
/** @typedef {import("./GraphQLUpload.js")} GraphQLUpload */
|
|
6
|
+
/** @typedef {import("./processRequest.js")} processRequest */
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* A file expected to be uploaded as it was declared in the `map` field of a
|
|
10
|
+
* [GraphQL multipart request](https://github.com/jaydenseric/graphql-multipart-request-spec).
|
|
11
|
+
* The {@linkcode processRequest} function places references to an instance of
|
|
12
|
+
* this class wherever the file is expected in the GraphQL operation. The scalar
|
|
13
|
+
* {@linkcode GraphQLUpload} derives it’s value from {@linkcode Upload.promise}.
|
|
14
|
+
*/
|
|
15
|
+
class Upload {
|
|
16
|
+
constructor() {
|
|
17
|
+
/**
|
|
18
|
+
* Promise that resolves file upload details. This should only be utilized
|
|
19
|
+
* by {@linkcode GraphQLUpload}.
|
|
20
|
+
* @type {Promise<import("./processRequest.js").FileUpload>}
|
|
21
|
+
*/
|
|
22
|
+
this.promise = new Promise((resolve, reject) => {
|
|
23
|
+
/**
|
|
24
|
+
* Resolves the upload promise with the file upload details. This should
|
|
25
|
+
* only be utilized by {@linkcode processRequest}.
|
|
26
|
+
* @param {import("./processRequest.js").FileUpload} file File upload
|
|
27
|
+
* details.
|
|
28
|
+
*/
|
|
29
|
+
this.resolve = (file) => {
|
|
30
|
+
/**
|
|
31
|
+
* The file upload details, available when the
|
|
32
|
+
* {@linkcode Upload.promise} resolves. This should only be utilized by
|
|
33
|
+
* {@linkcode processRequest}.
|
|
34
|
+
* @type {import("./processRequest.js").FileUpload | undefined}
|
|
35
|
+
*/
|
|
36
|
+
this.file = file;
|
|
37
|
+
|
|
38
|
+
resolve(file);
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Rejects the upload promise with an error. This should only be
|
|
43
|
+
* utilized by {@linkcode processRequest}.
|
|
44
|
+
* @param {Error} error Error instance.
|
|
45
|
+
*/
|
|
46
|
+
this.reject = reject;
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
// Prevent errors crashing Node.js, see:
|
|
50
|
+
// https://github.com/nodejs/node/issues/20392
|
|
51
|
+
this.promise.catch(() => {});
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
module.exports = Upload;
|
package/changelog.md
CHANGED
|
@@ -1,5 +1,81 @@
|
|
|
1
1
|
# graphql-upload changelog
|
|
2
2
|
|
|
3
|
+
## 15.0.0
|
|
4
|
+
|
|
5
|
+
### Major
|
|
6
|
+
|
|
7
|
+
- Updated the [`busboy`](https://npm.im/busboy) dependency to v1, fixing [#311](https://github.com/jaydenseric/graphql-upload/issues/311).
|
|
8
|
+
- This important update addresses the vulnerability [CVE-2022-24434](https://nvd.nist.gov/vuln/detail/CVE-2022-24434) ([GHSA-wm7h-9275-46v2](https://github.com/advisories/GHSA-wm7h-9275-46v2)).
|
|
9
|
+
- Some error messages have changed.
|
|
10
|
+
- Temporarily until [mscdex/busboy#297](https://github.com/mscdex/busboy/issues/297) is fixed upstream, for the function `processRequest` and the middleware `graphqlUploadExpress` and `graphqlUploadKoa` the option `maxFileSize` is actually 1 byte less than the amount specified.
|
|
11
|
+
|
|
12
|
+
### Patch
|
|
13
|
+
|
|
14
|
+
- Updated the [`typescript`](https://npm.im/typescript) dev dependency.
|
|
15
|
+
- In the function `processRequest` use the `on` method instead of `once` to listen for `error` events on the [`busboy`](https://npm.im/busboy) parser, as in edge cases the same parser could have multiple `error` events and all must be handled to prevent the Node.js process exiting with an error.
|
|
16
|
+
- Simplified error handling within the function `processRequest`.
|
|
17
|
+
- Added a test for the function `processRequest` with a maliciously malformed multipart request.
|
|
18
|
+
|
|
19
|
+
## 14.0.0
|
|
20
|
+
|
|
21
|
+
### Major
|
|
22
|
+
|
|
23
|
+
- Updated Node.js support to `^14.17.0 || ^16.0.0 || >= 18.0.0`.
|
|
24
|
+
- Updated the [`graphql`](https://npm.im/graphql) peer dependency to `^16.3.0`.
|
|
25
|
+
- Updated the [`http-errors`](https://npm.im/http-errors) dependency to v2.
|
|
26
|
+
- Public modules are now individually listed in the package `files` and `exports` fields.
|
|
27
|
+
- Removed the package main index module; deep imports must be used.
|
|
28
|
+
- Shortened public module deep import paths, removing the `/public/`.
|
|
29
|
+
- Implemented TypeScript types via JSDoc comments, closing [#282](https://github.com/jaydenseric/graphql-upload/issues/282).
|
|
30
|
+
- The `GraphQLUpload` scalar no longer uses deprecated `GraphQLError` constructor parameters.
|
|
31
|
+
|
|
32
|
+
### Patch
|
|
33
|
+
|
|
34
|
+
- Updated dev dependencies.
|
|
35
|
+
- Simplified dev dependencies and config for ESLint.
|
|
36
|
+
- Check TypeScript types via a new package `types` script.
|
|
37
|
+
- Removed the [`jsdoc-md`](https://npm.im/jsdoc-md) dev dependency and the related package scripts, replacing the readme “API” section with a manually written “Exports” section.
|
|
38
|
+
- Removed the [`hard-rejection`](https://npm.im/hard-rejection) dev dependency. Instead, tests are run with the Node.js CLI flag `--unhandled-rejections=throw` to make Node.js v14 behave like newer versions.
|
|
39
|
+
- Removed the [`formdata-node`](https://npm.im/formdata-node) dev dependency. Instead, `File` and `FormData` are imported from [`node-fetch`](https://npm.im/node-fetch).
|
|
40
|
+
- Updated GitHub Actions CI config:
|
|
41
|
+
- Run tests with Node.js v14, v16, v18.
|
|
42
|
+
- Updated `actions/checkout` to v3.
|
|
43
|
+
- Updated `actions/setup-node` to v3.
|
|
44
|
+
- Reorganized the test file structure.
|
|
45
|
+
- Use the `.js` file extension in `require` paths.
|
|
46
|
+
- Use the Node.js `Readable` property `readableEncoding` instead of `_readableState.encoding` in tests.
|
|
47
|
+
- Use `substring` instead of the deprecated string method `substr` in tests.
|
|
48
|
+
- Fixed a typo in a code comment.
|
|
49
|
+
- Updated documentation.
|
|
50
|
+
- Added a `license.md` MIT License file, closing [#86](https://github.com/jaydenseric/graphql-upload/issues/86).
|
|
51
|
+
|
|
52
|
+
## 13.0.0
|
|
53
|
+
|
|
54
|
+
### Major
|
|
55
|
+
|
|
56
|
+
- Updated Node.js support to `^12.22.0 || ^14.17.0 || >= 16.0.0`.
|
|
57
|
+
- Updated dev dependencies, some of which require newer Node.js versions than previously supported.
|
|
58
|
+
- Removed `./package` from the package `exports` field; the full `package.json` filename must be used in a `require` path.
|
|
59
|
+
|
|
60
|
+
### Patch
|
|
61
|
+
|
|
62
|
+
- Updated the [`graphql`](https://npm.im/graphql) peer dependency to `0.13.1 - 16`.
|
|
63
|
+
- Updated dependencies.
|
|
64
|
+
- Also run GitHub Actions CI with Node.js v17.
|
|
65
|
+
- Simplified package scripts.
|
|
66
|
+
- Renamed imports in the test index module.
|
|
67
|
+
- Test the `processRequest` function with a [GraphQL multipart request](https://github.com/jaydenseric/graphql-multipart-request-spec) that has no files.
|
|
68
|
+
- Test the `processRequest` function with an unparsable multipart request.
|
|
69
|
+
- Replaced the [`form-data`](https://npm.im/form-data) dev dependency with [`formdata-node`](https://npm.im/formdata-node), [`formdata-node`](https://npm.im/form-data-encoder), and [`node-abort-controller`](https://npm.im/node-abort-controller) and refactored tests to align with web standards.
|
|
70
|
+
- Refactored the `processRequest` function to remove the [`isobject`](https://npm.im/isobject) dependency.
|
|
71
|
+
- Improved the `processRequest` function, via [#273](https://github.com/jaydenseric/graphql-upload/pull/273):
|
|
72
|
+
- Fixed ending requests from being handled incorrectly as aborting in edge cases, closing [#272](https://github.com/jaydenseric/graphql-upload/pull/272).
|
|
73
|
+
- Fixed read streams created via the resolved `Upload` scalar value `createReadStream` method:
|
|
74
|
+
- Not emitting the `error` event when the multipart request is aborted certain ways while the file is uploading.
|
|
75
|
+
- Emitting incorrect `error` event details for multipart request file field parse errors.
|
|
76
|
+
- Configured Prettier option `singleQuote` to the default, `false`.
|
|
77
|
+
- Documentation tweaks.
|
|
78
|
+
|
|
3
79
|
## 12.0.0
|
|
4
80
|
|
|
5
81
|
### Major
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
// @ts-check
|
|
2
|
+
|
|
3
|
+
"use strict";
|
|
4
|
+
|
|
5
|
+
const defaultProcessRequest = require("./processRequest.js");
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Creates [Express](https://expressjs.com) middleware that processes incoming
|
|
9
|
+
* [GraphQL multipart requests](https://github.com/jaydenseric/graphql-multipart-request-spec)
|
|
10
|
+
* using {@linkcode processRequest}, ignoring non multipart requests. It sets
|
|
11
|
+
* the request `body` to be similar to a conventional GraphQL POST request for
|
|
12
|
+
* following GraphQL middleware to consume.
|
|
13
|
+
* @param {import("./processRequest.js").ProcessRequestOptions & {
|
|
14
|
+
* processRequest?: import("./processRequest.js").ProcessRequestFunction
|
|
15
|
+
* }} options Options.
|
|
16
|
+
* @returns Express middleware.
|
|
17
|
+
* @example
|
|
18
|
+
* Basic [`express-graphql`](https://npm.im/express-graphql) setup:
|
|
19
|
+
*
|
|
20
|
+
* ```js
|
|
21
|
+
* const express = require("express");
|
|
22
|
+
* const graphqlHTTP = require("express-graphql");
|
|
23
|
+
* const graphqlUploadExpress = require("graphql-upload/graphqlUploadExpress.js");
|
|
24
|
+
* const schema = require("./schema.js");
|
|
25
|
+
*
|
|
26
|
+
* express()
|
|
27
|
+
* .use(
|
|
28
|
+
* "/graphql",
|
|
29
|
+
* graphqlUploadExpress({ maxFileSize: 10000000, maxFiles: 10 }),
|
|
30
|
+
* graphqlHTTP({ schema })
|
|
31
|
+
* )
|
|
32
|
+
* .listen(3000);
|
|
33
|
+
* ```
|
|
34
|
+
*/
|
|
35
|
+
function graphqlUploadExpress({
|
|
36
|
+
processRequest = defaultProcessRequest,
|
|
37
|
+
...processRequestOptions
|
|
38
|
+
} = {}) {
|
|
39
|
+
/**
|
|
40
|
+
* [Express](https://expressjs.com) middleware that processes incoming
|
|
41
|
+
* [GraphQL multipart requests](https://github.com/jaydenseric/graphql-multipart-request-spec)
|
|
42
|
+
* using {@linkcode processRequest}, ignoring non multipart requests. It sets
|
|
43
|
+
* the request `body` to be similar to a conventional GraphQL POST request for
|
|
44
|
+
* following GraphQL middleware to consume.
|
|
45
|
+
* @param {import("express").Request} request
|
|
46
|
+
* @param {import("express").Response} response
|
|
47
|
+
* @param {import("express").NextFunction} next
|
|
48
|
+
*/
|
|
49
|
+
function graphqlUploadExpressMiddleware(request, response, next) {
|
|
50
|
+
if (!request.is("multipart/form-data")) return next();
|
|
51
|
+
|
|
52
|
+
const requestEnd = new Promise((resolve) => request.on("end", resolve));
|
|
53
|
+
const { send } = response;
|
|
54
|
+
|
|
55
|
+
// @ts-ignore Todo: Find a less hacky way to prevent sending a response
|
|
56
|
+
// before the request has ended.
|
|
57
|
+
response.send =
|
|
58
|
+
/** @param {Array<unknown>} args */
|
|
59
|
+
(...args) => {
|
|
60
|
+
requestEnd.then(() => {
|
|
61
|
+
response.send = send;
|
|
62
|
+
response.send(...args);
|
|
63
|
+
});
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
processRequest(request, response, processRequestOptions)
|
|
67
|
+
.then((body) => {
|
|
68
|
+
request.body = body;
|
|
69
|
+
next();
|
|
70
|
+
})
|
|
71
|
+
.catch((error) => {
|
|
72
|
+
if (error.status && error.expose) response.status(error.status);
|
|
73
|
+
next(error);
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
return graphqlUploadExpressMiddleware;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
module.exports = graphqlUploadExpress;
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
// @ts-check
|
|
2
|
+
|
|
3
|
+
"use strict";
|
|
4
|
+
|
|
5
|
+
const defaultProcessRequest = require("./processRequest.js");
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Creates [Koa](https://koajs.com) middleware that processes incoming
|
|
9
|
+
* [GraphQL multipart requests](https://github.com/jaydenseric/graphql-multipart-request-spec)
|
|
10
|
+
* using {@linkcode processRequest}, ignoring non multipart requests. It sets
|
|
11
|
+
* the request `body` to be similar to a conventional GraphQL POST request for
|
|
12
|
+
* following GraphQL middleware to consume.
|
|
13
|
+
* @param {import("./processRequest.js").ProcessRequestOptions & {
|
|
14
|
+
* processRequest?: import("./processRequest.js").ProcessRequestFunction
|
|
15
|
+
* }} options Options.
|
|
16
|
+
* @returns Koa middleware.
|
|
17
|
+
* @example
|
|
18
|
+
* Basic [`graphql-api-koa`](https://npm.im/graphql-api-koa) setup:
|
|
19
|
+
*
|
|
20
|
+
* ```js
|
|
21
|
+
* const Koa = require("koa");
|
|
22
|
+
* const bodyParser = require("koa-bodyparser");
|
|
23
|
+
* const { errorHandler, execute } = require("graphql-api-koa");
|
|
24
|
+
* const graphqlUploadKoa = require("graphql-upload/graphqlUploadKoa.js");
|
|
25
|
+
* const schema = require("./schema.js");
|
|
26
|
+
*
|
|
27
|
+
* new Koa()
|
|
28
|
+
* .use(errorHandler())
|
|
29
|
+
* .use(bodyParser())
|
|
30
|
+
* .use(graphqlUploadKoa({ maxFileSize: 10000000, maxFiles: 10 }))
|
|
31
|
+
* .use(execute({ schema }))
|
|
32
|
+
* .listen(3000);
|
|
33
|
+
* ```
|
|
34
|
+
*/
|
|
35
|
+
function graphqlUploadKoa({
|
|
36
|
+
processRequest = defaultProcessRequest,
|
|
37
|
+
...processRequestOptions
|
|
38
|
+
} = {}) {
|
|
39
|
+
/**
|
|
40
|
+
* [Koa](https://koajs.com) middleware that processes incoming
|
|
41
|
+
* [GraphQL multipart requests](https://github.com/jaydenseric/graphql-multipart-request-spec)
|
|
42
|
+
* using {@linkcode processRequest}, ignoring non multipart requests. It sets
|
|
43
|
+
* the request `body` to be similar to a conventional GraphQL POST request for
|
|
44
|
+
* following GraphQL middleware to consume.
|
|
45
|
+
* @param {import("koa").Context} ctx
|
|
46
|
+
* @param {() => Promise<unknown>} next
|
|
47
|
+
*/
|
|
48
|
+
async function graphqlUploadKoaMiddleware(ctx, next) {
|
|
49
|
+
if (!ctx.request.is("multipart/form-data")) return next();
|
|
50
|
+
|
|
51
|
+
const requestEnd = new Promise((resolve) => ctx.req.on("end", resolve));
|
|
52
|
+
|
|
53
|
+
try {
|
|
54
|
+
// @ts-ignore This is conventional.
|
|
55
|
+
ctx.request.body = await processRequest(
|
|
56
|
+
ctx.req,
|
|
57
|
+
ctx.res,
|
|
58
|
+
processRequestOptions
|
|
59
|
+
);
|
|
60
|
+
await next();
|
|
61
|
+
} finally {
|
|
62
|
+
await requestEnd;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
return graphqlUploadKoaMiddleware;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
module.exports = graphqlUploadKoa;
|
package/ignoreStream.js
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
// @ts-check
|
|
2
|
+
|
|
3
|
+
"use strict";
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Safely ignores a Node.js readable stream.
|
|
7
|
+
* @param {import("stream").Readable} stream Node.js readable stream.
|
|
8
|
+
*/
|
|
9
|
+
function ignoreStream(stream) {
|
|
10
|
+
// Prevent an unhandled error from crashing the process.
|
|
11
|
+
stream.on("error", () => {});
|
|
12
|
+
|
|
13
|
+
// Waste the stream.
|
|
14
|
+
stream.resume();
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
module.exports = ignoreStream;
|
package/license.md
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
# MIT License
|
|
2
|
+
|
|
3
|
+
Copyright Jayden Seric
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
6
|
+
|
|
7
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
8
|
+
|
|
9
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "graphql-upload",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "15.0.0",
|
|
4
4
|
"description": "Middleware and an Upload scalar to add support for GraphQL multipart requests (file uploads via queries and mutations) to various Node.js GraphQL servers.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": {
|
|
@@ -27,59 +27,70 @@
|
|
|
27
27
|
"mjs"
|
|
28
28
|
],
|
|
29
29
|
"files": [
|
|
30
|
-
"
|
|
31
|
-
"
|
|
30
|
+
"GRAPHQL_MULTIPART_REQUEST_SPEC_URL.js",
|
|
31
|
+
"GraphQLUpload.js",
|
|
32
|
+
"graphqlUploadExpress.js",
|
|
33
|
+
"graphqlUploadKoa.js",
|
|
34
|
+
"ignoreStream.js",
|
|
35
|
+
"processRequest.js",
|
|
36
|
+
"Upload.js"
|
|
32
37
|
],
|
|
33
38
|
"sideEffects": false,
|
|
34
|
-
"main": "./public/index.js",
|
|
35
39
|
"exports": {
|
|
36
|
-
".":
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
"./
|
|
41
|
-
"./
|
|
42
|
-
"./package.json": "./package.json"
|
|
40
|
+
"./GraphQLUpload.js": "./GraphQLUpload.js",
|
|
41
|
+
"./graphqlUploadExpress.js": "./graphqlUploadExpress.js",
|
|
42
|
+
"./graphqlUploadKoa.js": "./graphqlUploadKoa.js",
|
|
43
|
+
"./package.json": "./package.json",
|
|
44
|
+
"./processRequest.js": "./processRequest.js",
|
|
45
|
+
"./Upload.js": "./Upload.js"
|
|
43
46
|
},
|
|
44
47
|
"engines": {
|
|
45
|
-
"node": "^
|
|
48
|
+
"node": "^14.17.0 || ^16.0.0 || >= 18.0.0"
|
|
46
49
|
},
|
|
47
50
|
"peerDependencies": {
|
|
48
|
-
"
|
|
51
|
+
"@types/express": "^4.0.29",
|
|
52
|
+
"@types/koa": "^2.11.4",
|
|
53
|
+
"graphql": "^16.3.0"
|
|
54
|
+
},
|
|
55
|
+
"peerDependenciesMeta": {
|
|
56
|
+
"@types/express": {
|
|
57
|
+
"optional": true
|
|
58
|
+
},
|
|
59
|
+
"@types/koa": {
|
|
60
|
+
"optional": true
|
|
61
|
+
}
|
|
49
62
|
},
|
|
50
63
|
"dependencies": {
|
|
51
|
-
"busboy": "^
|
|
64
|
+
"@types/busboy": "^1.5.0",
|
|
65
|
+
"@types/node": "*",
|
|
66
|
+
"@types/object-path": "^0.11.1",
|
|
67
|
+
"busboy": "^1.6.0",
|
|
52
68
|
"fs-capacitor": "^6.2.0",
|
|
53
|
-
"http-errors": "^
|
|
54
|
-
"
|
|
55
|
-
"object-path": "^0.11.5"
|
|
69
|
+
"http-errors": "^2.0.0",
|
|
70
|
+
"object-path": "^0.11.8"
|
|
56
71
|
},
|
|
57
72
|
"devDependencies": {
|
|
58
|
-
"
|
|
59
|
-
"
|
|
60
|
-
"
|
|
61
|
-
"eslint
|
|
62
|
-
"eslint-plugin-import": "^
|
|
63
|
-
"
|
|
64
|
-
"
|
|
65
|
-
"
|
|
66
|
-
"
|
|
67
|
-
"
|
|
68
|
-
"
|
|
69
|
-
"
|
|
70
|
-
"
|
|
71
|
-
"
|
|
72
|
-
"node-fetch": "^2.6.1",
|
|
73
|
-
"prettier": "^2.2.1",
|
|
74
|
-
"test-director": "^6.0.0"
|
|
73
|
+
"@types/express": "^4.17.13",
|
|
74
|
+
"@types/koa": "^2.13.4",
|
|
75
|
+
"coverage-node": "^6.1.0",
|
|
76
|
+
"eslint": "^8.16.0",
|
|
77
|
+
"eslint-plugin-simple-import-sort": "^7.0.0",
|
|
78
|
+
"express": "^4.18.0",
|
|
79
|
+
"form-data-encoder": "^2.0.1",
|
|
80
|
+
"graphql": "^16.5.0",
|
|
81
|
+
"koa": "^2.13.4",
|
|
82
|
+
"node-abort-controller": "^3.0.1",
|
|
83
|
+
"node-fetch": "^3.2.3",
|
|
84
|
+
"prettier": "^2.6.2",
|
|
85
|
+
"test-director": "^8.0.2",
|
|
86
|
+
"typescript": "^4.7.2"
|
|
75
87
|
},
|
|
76
88
|
"scripts": {
|
|
77
|
-
"
|
|
78
|
-
"
|
|
79
|
-
"
|
|
80
|
-
"
|
|
81
|
-
"test
|
|
82
|
-
"test:api": "coverage-node -r hard-rejection/register test/index.mjs",
|
|
89
|
+
"eslint": "eslint .",
|
|
90
|
+
"prettier": "prettier -c .",
|
|
91
|
+
"types": "tsc -p jsconfig.json",
|
|
92
|
+
"tests": "coverage-node --unhandled-rejections=throw test.mjs",
|
|
93
|
+
"test": "npm run eslint && npm run prettier && npm run types && npm run tests",
|
|
83
94
|
"prepublishOnly": "npm test"
|
|
84
95
|
}
|
|
85
96
|
}
|