graphql-upload 15.0.0 → 16.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.
@@ -1,7 +1,5 @@
1
1
  // @ts-check
2
2
 
3
- "use strict";
4
-
5
3
  /**
6
4
  * [GraphQL multipart request spec](https://github.com/jaydenseric/graphql-multipart-request-spec)
7
5
  * URL. Useful for error messages, etc.
@@ -9,4 +7,4 @@
9
7
  const GRAPHQL_MULTIPART_REQUEST_SPEC_URL =
10
8
  "https://github.com/jaydenseric/graphql-multipart-request-spec";
11
9
 
12
- module.exports = GRAPHQL_MULTIPART_REQUEST_SPEC_URL;
10
+ export default GRAPHQL_MULTIPART_REQUEST_SPEC_URL;
@@ -1,11 +1,10 @@
1
1
  // @ts-check
2
2
 
3
- "use strict";
3
+ import { GraphQLError, GraphQLScalarType } from "graphql";
4
4
 
5
- const { GraphQLScalarType, GraphQLError } = require("graphql");
6
- const Upload = require("./Upload.js");
5
+ import Upload from "./Upload.mjs";
7
6
 
8
- /** @typedef {import("./processRequest").FileUpload} FileUpload */
7
+ /** @typedef {import("./processRequest.mjs").FileUpload} FileUpload */
9
8
 
10
9
  /**
11
10
  * A GraphQL `Upload` scalar that can be used in a
@@ -18,8 +17,8 @@ const Upload = require("./Upload.js");
18
17
  * from [`@graphql-tools/schema`](https://npm.im/@graphql-tools/schema):
19
18
  *
20
19
  * ```js
21
- * const { makeExecutableSchema } = require("@graphql-tools/schema");
22
- * const GraphQLUpload = require("graphql-upload/GraphQLUpload.js");
20
+ * import { makeExecutableSchema } from "@graphql-tools/schema/makeExecutableSchema";
21
+ * import GraphQLUpload from "graphql-upload/GraphQLUpload.mjs";
23
22
  *
24
23
  * const schema = makeExecutableSchema({
25
24
  * typeDefs: `
@@ -34,8 +33,8 @@ const Upload = require("./Upload.js");
34
33
  * A manually constructed schema with an image upload mutation:
35
34
  *
36
35
  * ```js
37
- * const { GraphQLSchema, GraphQLObjectType, GraphQLBoolean } = require("graphql");
38
- * const GraphQLUpload = require("graphql-upload/GraphQLUpload.js");
36
+ * import { GraphQLBoolean, GraphQLObjectType, GraphQLSchema } from "graphql";
37
+ * import GraphQLUpload from "graphql-upload/GraphQLUpload.mjs";
39
38
  *
40
39
  * const schema = new GraphQLSchema({
41
40
  * mutation: new GraphQLObjectType({
@@ -77,4 +76,4 @@ const GraphQLUpload = new GraphQLScalarType({
77
76
  },
78
77
  });
79
78
 
80
- module.exports = GraphQLUpload;
79
+ export default GraphQLUpload;
@@ -1,9 +1,7 @@
1
1
  // @ts-check
2
2
 
3
- "use strict";
4
-
5
- /** @typedef {import("./GraphQLUpload.js")} GraphQLUpload */
6
- /** @typedef {import("./processRequest.js")} processRequest */
3
+ /** @typedef {import("./GraphQLUpload.mjs").default} GraphQLUpload */
4
+ /** @typedef {import("./processRequest.mjs").default} processRequest */
7
5
 
8
6
  /**
9
7
  * A file expected to be uploaded as it was declared in the `map` field of a
@@ -12,18 +10,18 @@
12
10
  * this class wherever the file is expected in the GraphQL operation. The scalar
13
11
  * {@linkcode GraphQLUpload} derives it’s value from {@linkcode Upload.promise}.
14
12
  */
15
- class Upload {
13
+ export default class Upload {
16
14
  constructor() {
17
15
  /**
18
16
  * Promise that resolves file upload details. This should only be utilized
19
17
  * by {@linkcode GraphQLUpload}.
20
- * @type {Promise<import("./processRequest.js").FileUpload>}
18
+ * @type {Promise<import("./processRequest.mjs").FileUpload>}
21
19
  */
22
20
  this.promise = new Promise((resolve, reject) => {
23
21
  /**
24
22
  * Resolves the upload promise with the file upload details. This should
25
23
  * only be utilized by {@linkcode processRequest}.
26
- * @param {import("./processRequest.js").FileUpload} file File upload
24
+ * @param {import("./processRequest.mjs").FileUpload} file File upload
27
25
  * details.
28
26
  */
29
27
  this.resolve = (file) => {
@@ -31,7 +29,7 @@ class Upload {
31
29
  * The file upload details, available when the
32
30
  * {@linkcode Upload.promise} resolves. This should only be utilized by
33
31
  * {@linkcode processRequest}.
34
- * @type {import("./processRequest.js").FileUpload | undefined}
32
+ * @type {import("./processRequest.mjs").FileUpload | undefined}
35
33
  */
36
34
  this.file = file;
37
35
 
@@ -51,5 +49,3 @@ class Upload {
51
49
  this.promise.catch(() => {});
52
50
  }
53
51
  }
54
-
55
- module.exports = Upload;
@@ -1,8 +1,6 @@
1
1
  // @ts-check
2
2
 
3
- "use strict";
4
-
5
- const defaultProcessRequest = require("./processRequest.js");
3
+ import defaultProcessRequest from "./processRequest.mjs";
6
4
 
7
5
  /**
8
6
  * Creates [Express](https://expressjs.com) middleware that processes incoming
@@ -10,29 +8,30 @@ const defaultProcessRequest = require("./processRequest.js");
10
8
  * using {@linkcode processRequest}, ignoring non multipart requests. It sets
11
9
  * the request `body` to be similar to a conventional GraphQL POST request for
12
10
  * following GraphQL middleware to consume.
13
- * @param {import("./processRequest.js").ProcessRequestOptions & {
14
- * processRequest?: import("./processRequest.js").ProcessRequestFunction
11
+ * @param {import("./processRequest.mjs").ProcessRequestOptions & {
12
+ * processRequest?: import("./processRequest.mjs").ProcessRequestFunction
15
13
  * }} options Options.
16
14
  * @returns Express middleware.
17
15
  * @example
18
16
  * Basic [`express-graphql`](https://npm.im/express-graphql) setup:
19
17
  *
20
18
  * ```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");
19
+ * import express from "express";
20
+ * import expressGraphQL from "express-graphql";
21
+ * import graphqlUploadExpress from "graphql-upload/graphqlUploadExpress.mjs";
22
+ *
23
+ * import schema from "./schema.mjs";
25
24
  *
26
25
  * express()
27
26
  * .use(
28
27
  * "/graphql",
29
28
  * graphqlUploadExpress({ maxFileSize: 10000000, maxFiles: 10 }),
30
- * graphqlHTTP({ schema })
29
+ * expressGraphQL.graphqlHTTP({ schema })
31
30
  * )
32
31
  * .listen(3000);
33
32
  * ```
34
33
  */
35
- function graphqlUploadExpress({
34
+ export default function graphqlUploadExpress({
36
35
  processRequest = defaultProcessRequest,
37
36
  ...processRequestOptions
38
37
  } = {}) {
@@ -76,5 +75,3 @@ function graphqlUploadExpress({
76
75
 
77
76
  return graphqlUploadExpressMiddleware;
78
77
  }
79
-
80
- module.exports = graphqlUploadExpress;
@@ -1,8 +1,6 @@
1
1
  // @ts-check
2
2
 
3
- "use strict";
4
-
5
- const defaultProcessRequest = require("./processRequest.js");
3
+ import defaultProcessRequest from "./processRequest.mjs";
6
4
 
7
5
  /**
8
6
  * Creates [Koa](https://koajs.com) middleware that processes incoming
@@ -10,19 +8,21 @@ const defaultProcessRequest = require("./processRequest.js");
10
8
  * using {@linkcode processRequest}, ignoring non multipart requests. It sets
11
9
  * the request `body` to be similar to a conventional GraphQL POST request for
12
10
  * following GraphQL middleware to consume.
13
- * @param {import("./processRequest.js").ProcessRequestOptions & {
14
- * processRequest?: import("./processRequest.js").ProcessRequestFunction
11
+ * @param {import("./processRequest.mjs").ProcessRequestOptions & {
12
+ * processRequest?: import("./processRequest.mjs").ProcessRequestFunction
15
13
  * }} options Options.
16
14
  * @returns Koa middleware.
17
15
  * @example
18
16
  * Basic [`graphql-api-koa`](https://npm.im/graphql-api-koa) setup:
19
17
  *
20
18
  * ```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");
19
+ * import errorHandler from "graphql-api-koa/errorHandler.mjs";
20
+ * import execute from "graphql-api-koa/execute.mjs";
21
+ * import graphqlUploadKoa from "graphql-upload/graphqlUploadKoa.mjs";
22
+ * import Koa from "koa";
23
+ * import bodyParser from "koa-bodyparser";
24
+ *
25
+ * import schema from "./schema.mjs";
26
26
  *
27
27
  * new Koa()
28
28
  * .use(errorHandler())
@@ -32,7 +32,7 @@ const defaultProcessRequest = require("./processRequest.js");
32
32
  * .listen(3000);
33
33
  * ```
34
34
  */
35
- function graphqlUploadKoa({
35
+ export default function graphqlUploadKoa({
36
36
  processRequest = defaultProcessRequest,
37
37
  ...processRequestOptions
38
38
  } = {}) {
@@ -42,7 +42,7 @@ function graphqlUploadKoa({
42
42
  * using {@linkcode processRequest}, ignoring non multipart requests. It sets
43
43
  * the request `body` to be similar to a conventional GraphQL POST request for
44
44
  * following GraphQL middleware to consume.
45
- * @param {import("koa").Context} ctx
45
+ * @param {import("koa").ParameterizedContext} ctx
46
46
  * @param {() => Promise<unknown>} next
47
47
  */
48
48
  async function graphqlUploadKoaMiddleware(ctx, next) {
@@ -65,5 +65,3 @@ function graphqlUploadKoa({
65
65
 
66
66
  return graphqlUploadKoaMiddleware;
67
67
  }
68
-
69
- module.exports = graphqlUploadKoa;
@@ -1,17 +1,13 @@
1
1
  // @ts-check
2
2
 
3
- "use strict";
4
-
5
3
  /**
6
4
  * Safely ignores a Node.js readable stream.
7
5
  * @param {import("stream").Readable} stream Node.js readable stream.
8
6
  */
9
- function ignoreStream(stream) {
7
+ export default function ignoreStream(stream) {
10
8
  // Prevent an unhandled error from crashing the process.
11
9
  stream.on("error", () => {});
12
10
 
13
11
  // Waste the stream.
14
12
  stream.resume();
15
13
  }
16
-
17
- module.exports = ignoreStream;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "graphql-upload",
3
- "version": "15.0.0",
3
+ "version": "16.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,22 +27,22 @@
27
27
  "mjs"
28
28
  ],
29
29
  "files": [
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"
30
+ "GRAPHQL_MULTIPART_REQUEST_SPEC_URL.mjs",
31
+ "GraphQLUpload.mjs",
32
+ "graphqlUploadExpress.mjs",
33
+ "graphqlUploadKoa.mjs",
34
+ "ignoreStream.mjs",
35
+ "processRequest.mjs",
36
+ "Upload.mjs"
37
37
  ],
38
38
  "sideEffects": false,
39
39
  "exports": {
40
- "./GraphQLUpload.js": "./GraphQLUpload.js",
41
- "./graphqlUploadExpress.js": "./graphqlUploadExpress.js",
42
- "./graphqlUploadKoa.js": "./graphqlUploadKoa.js",
40
+ "./GraphQLUpload.mjs": "./GraphQLUpload.mjs",
41
+ "./graphqlUploadExpress.mjs": "./graphqlUploadExpress.mjs",
42
+ "./graphqlUploadKoa.mjs": "./graphqlUploadKoa.mjs",
43
43
  "./package.json": "./package.json",
44
- "./processRequest.js": "./processRequest.js",
45
- "./Upload.js": "./Upload.js"
44
+ "./processRequest.mjs": "./processRequest.mjs",
45
+ "./Upload.mjs": "./Upload.mjs"
46
46
  },
47
47
  "engines": {
48
48
  "node": "^14.17.0 || ^16.0.0 || >= 18.0.0"
@@ -65,25 +65,25 @@
65
65
  "@types/node": "*",
66
66
  "@types/object-path": "^0.11.1",
67
67
  "busboy": "^1.6.0",
68
- "fs-capacitor": "^6.2.0",
68
+ "fs-capacitor": "^8.0.0",
69
69
  "http-errors": "^2.0.0",
70
70
  "object-path": "^0.11.8"
71
71
  },
72
72
  "devDependencies": {
73
73
  "@types/express": "^4.17.13",
74
- "@types/koa": "^2.13.4",
74
+ "@types/koa": "^2.13.5",
75
75
  "coverage-node": "^6.1.0",
76
- "eslint": "^8.16.0",
76
+ "eslint": "^8.20.0",
77
77
  "eslint-plugin-simple-import-sort": "^7.0.0",
78
- "express": "^4.18.0",
78
+ "express": "^4.18.1",
79
79
  "form-data-encoder": "^2.0.1",
80
80
  "graphql": "^16.5.0",
81
81
  "koa": "^2.13.4",
82
82
  "node-abort-controller": "^3.0.1",
83
- "node-fetch": "^3.2.3",
83
+ "node-fetch": "^3.2.9",
84
84
  "prettier": "^2.6.2",
85
85
  "test-director": "^8.0.2",
86
- "typescript": "^4.7.2"
86
+ "typescript": "^4.7.4"
87
87
  },
88
88
  "scripts": {
89
89
  "eslint": "eslint .",
@@ -1,18 +1,15 @@
1
1
  // @ts-check
2
2
 
3
- "use strict";
3
+ import busboy from "busboy";
4
+ import { WriteStream } from "fs-capacitor";
5
+ import createError from "http-errors";
6
+ import objectPath from "object-path";
4
7
 
5
- const busboy = require("busboy");
6
- const { WriteStream } = require("fs-capacitor");
7
- const createError = require("http-errors");
8
- const objectPath = require("object-path");
9
- const GRAPHQL_MULTIPART_REQUEST_SPEC_URL = require("./GRAPHQL_MULTIPART_REQUEST_SPEC_URL.js");
10
- const ignoreStream = require("./ignoreStream.js");
11
- const Upload = require("./Upload.js");
8
+ import GRAPHQL_MULTIPART_REQUEST_SPEC_URL from "./GRAPHQL_MULTIPART_REQUEST_SPEC_URL.mjs";
9
+ import ignoreStream from "./ignoreStream.mjs";
10
+ import Upload from "./Upload.mjs";
12
11
 
13
- /** @typedef {import("./GraphQLUpload.js")} GraphQLUpload */
14
- /** @typedef {import("./graphqlUploadExpress.js")} graphqlUploadExpress */
15
- /** @typedef {import("./graphqlUploadKoa.js")} graphqlUploadKoa */
12
+ /** @typedef {import("./GraphQLUpload.mjs").default} GraphQLUpload */
16
13
 
17
14
  /**
18
15
  * Processes an incoming
@@ -22,11 +19,10 @@ const Upload = require("./Upload.js");
22
19
  * is expected in the GraphQL operation for the {@linkcode GraphQLUpload} scalar
23
20
  * to derive it’s value. Errors are created with
24
21
  * [`http-errors`](https://npm.im/http-errors) to assist in sending responses
25
- * with appropriate HTTP status codes. Used to create custom middleware and is
26
- * used by {@linkcode graphqlUploadExpress} and {@linkcode graphqlUploadKoa}.
22
+ * with appropriate HTTP status codes. Used to create custom middleware.
27
23
  * @type {ProcessRequestFunction}
28
24
  */
29
- function processRequest(
25
+ export default function processRequest(
30
26
  request,
31
27
  response,
32
28
  {
@@ -349,8 +345,6 @@ function processRequest(
349
345
  });
350
346
  }
351
347
 
352
- module.exports = processRequest;
353
-
354
348
  /**
355
349
  * File upload details that are only available after the file’s field in the
356
350
  * [GraphQL multipart request](https://github.com/jaydenseric/graphql-multipart-request-spec)
@@ -386,17 +380,19 @@ module.exports = processRequest;
386
380
  /**
387
381
  * {@linkcode FileUploadCreateReadStream} options.
388
382
  * @typedef {object} FileUploadCreateReadStreamOptions
389
- * @prop {string} [options.encoding] Specify an encoding for the
390
- * [`data`](https://nodejs.org/api/stream.html#event-data) chunks to be
383
+ * @prop {import("fs-capacitor")
384
+ * .ReadStreamOptions["encoding"]} [options.encoding] Specify an encoding for
385
+ * the [`data`](https://nodejs.org/api/stream.html#event-data) chunks to be
391
386
  * strings (without splitting multi-byte characters across chunks) instead of
392
387
  * Node.js [`Buffer`](https://nodejs.org/api/buffer.html#buffer) instances.
393
388
  * Supported values depend on the
394
389
  * [`Buffer` implementation](https://github.com/nodejs/node/blob/v18.1.0/lib/buffer.js#L590-L680)
395
390
  * and include `utf8`, `ucs2`, `utf16le`, `latin1`, `ascii`, `base64`,
396
391
  * `base64url`, or `hex`. Defaults to `utf8`.
397
- * @prop {number} [options.highWaterMark] Maximum number of bytes to store in
398
- * the internal buffer before ceasing to read from the underlying resource.
399
- * Defaults to `16384`.
392
+ * @prop {import("fs-capacitor")
393
+ * .ReadStreamOptions["highWaterMark"]} [options.highWaterMark] Maximum number
394
+ * of bytes to store in the internal buffer before ceasing to read from the
395
+ * underlying resource. Defaults to `16384`.
400
396
  */
401
397
 
402
398
  /**
package/readme.md CHANGED
@@ -4,7 +4,7 @@
4
4
 
5
5
  [![npm version](https://badgen.net/npm/v/graphql-upload)](https://npm.im/graphql-upload) [![CI status](https://github.com/jaydenseric/graphql-upload/workflows/CI/badge.svg)](https://github.com/jaydenseric/graphql-upload/actions)
6
6
 
7
- Middleware and an [`Upload`](./GraphQLUpload.js) scalar to add support for [GraphQL multipart requests](https://github.com/jaydenseric/graphql-multipart-request-spec) (file uploads via queries and mutations) to various Node.js GraphQL servers.
7
+ Middleware and an [`Upload`](./GraphQLUpload.mjs) scalar to add support for [GraphQL multipart requests](https://github.com/jaydenseric/graphql-multipart-request-spec) (file uploads via queries and mutations) to various Node.js GraphQL servers.
8
8
 
9
9
  ## Installation
10
10
 
@@ -16,13 +16,13 @@ To install [`graphql-upload`](https://npm.im/graphql-upload) and the [`graphql`]
16
16
  npm install graphql-upload graphql
17
17
  ```
18
18
 
19
- Use the [`graphqlUploadKoa`](./graphqlUploadKoa.js) or [`graphqlUploadExpress`](./graphqlUploadExpress.js) middleware just before GraphQL middleware. Alternatively, use [`processRequest`](./processRequest.js) to create custom middleware.
19
+ Use the [`graphqlUploadKoa`](./graphqlUploadKoa.mjs) or [`graphqlUploadExpress`](./graphqlUploadExpress.mjs) middleware just before GraphQL middleware. Alternatively, use [`processRequest`](./processRequest.mjs) to create custom middleware.
20
20
 
21
- A schema built with separate SDL and resolvers (e.g. using [`makeExecutableSchema`](https://www.graphql-tools.com/docs/api/modules/schema_src#makeexecutableschema) from [`@graphql-tools/schema`](https://npm.im/@graphql-tools/schema)) requires the [`Upload`](./GraphQLUpload.js) scalar to be setup.
21
+ A schema built with separate SDL and resolvers (e.g. using [`makeExecutableSchema`](https://www.graphql-tools.com/docs/api/modules/schema_src#makeexecutableschema) from [`@graphql-tools/schema`](https://npm.im/@graphql-tools/schema)) requires the [`Upload`](./GraphQLUpload.mjs) scalar to be setup.
22
22
 
23
23
  ## Usage
24
24
 
25
- [Clients implementing the GraphQL multipart request spec](https://github.com/jaydenseric/graphql-multipart-request-spec#client) upload files as [`Upload`](./GraphQLUpload.js) scalar query or mutation variables. Their resolver values are promises that resolve file upload details for processing and storage. Files are typically streamed into cloud storage but may also be stored in the filesystem.
25
+ [Clients implementing the GraphQL multipart request spec](https://github.com/jaydenseric/graphql-multipart-request-spec#client) upload files as [`Upload`](./GraphQLUpload.mjs) scalar query or mutation variables. Their resolver values are promises that resolve file upload details for processing and storage. Files are typically streamed into cloud storage but may also be stored in the filesystem.
26
26
 
27
27
  See the [example API and client](https://github.com/jaydenseric/apollo-upload-examples).
28
28
 
@@ -40,7 +40,7 @@ See the [example API and client](https://github.com/jaydenseric/apollo-upload-ex
40
40
 
41
41
  The [GraphQL multipart request spec](https://github.com/jaydenseric/graphql-multipart-request-spec) allows a file to be used for multiple query or mutation variables (file deduplication), and for variables to be used in multiple places. GraphQL resolvers need to be able to manage independent file streams. As resolvers are executed asynchronously, it’s possible they will try to process files in a different order than received in the multipart request.
42
42
 
43
- [`busboy`](https://npm.im/busboy) parses multipart request streams. Once the `operations` and `map` fields have been parsed, [`Upload`](./GraphQLUpload.js) scalar values in the GraphQL operations are populated with promises, and the operations are passed down the middleware chain to GraphQL resolvers.
43
+ [`busboy`](https://npm.im/busboy) parses multipart request streams. Once the `operations` and `map` fields have been parsed, [`Upload`](./GraphQLUpload.mjs) scalar values in the GraphQL operations are populated with promises, and the operations are passed down the middleware chain to GraphQL resolvers.
44
44
 
45
45
  [`fs-capacitor`](https://npm.im/fs-capacitor) is used to buffer file uploads to the filesystem and coordinate simultaneous reading and writing. As soon as a file upload’s contents begins streaming, its data begins buffering to the filesystem and its associated promise resolves. GraphQL resolvers can then create new streams from the buffer by calling the function `createReadStream`. The buffer is destroyed once all streams have ended or closed and the server has responded to the request. Any remaining buffer files will be cleaned when the process exits.
46
46
 
@@ -50,10 +50,10 @@ The [GraphQL multipart request spec](https://github.com/jaydenseric/graphql-mult
50
50
 
51
51
  ## Exports
52
52
 
53
- These CommonJS modules are published to [npm](https://npmjs.com) and exported via the [`package.json`](./package.json) `exports` field:
53
+ These ECMAScript modules are published to [npm](https://npmjs.com) and exported via the [`package.json`](./package.json) `exports` field:
54
54
 
55
- - [`GraphQLUpload.js`](./GraphQLUpload.js)
56
- - [`graphqlUploadExpress.js`](./graphqlUploadExpress.js)
57
- - [`graphqlUploadKoa.js`](./graphqlUploadKoa.js)
58
- - [`processRequest.js`](./processRequest.js)
59
- - [`Upload.js`](./Upload.js)
55
+ - [`GraphQLUpload.mjs`](./GraphQLUpload.mjs)
56
+ - [`graphqlUploadExpress.mjs`](./graphqlUploadExpress.mjs)
57
+ - [`graphqlUploadKoa.mjs`](./graphqlUploadKoa.mjs)
58
+ - [`processRequest.mjs`](./processRequest.mjs)
59
+ - [`Upload.mjs`](./Upload.mjs)
package/changelog.md DELETED
@@ -1,606 +0,0 @@
1
- # graphql-upload changelog
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
-
79
- ## 12.0.0
80
-
81
- ### Major
82
-
83
- - Updated Node.js support to `^12.20 || >= 14.13`.
84
- - Updated dev dependencies, some of which require newer Node.js versions than previously supported.
85
- - The tests are now ESM in `.mjs` files instead of CJS in `.js` files.
86
- - Replaced the the `package.json` `exports` field public [subpath folder mapping](https://nodejs.org/api/packages.html#packages_subpath_folder_mappings) (deprecated by Node.js) with a [subpath pattern](https://nodejs.org/api/packages.html#packages_subpath_patterns). Deep `require` paths must now include the `.js` file extension.
87
-
88
- ### Minor
89
-
90
- - Added a package `sideEffects` field.
91
-
92
- ### Patch
93
-
94
- - Updated dependencies.
95
- - Lint fixes for the updated Prettier version.
96
- - Updated GitHub Actions CI config:
97
- - Updated the tested Node.js versions to v12, v14, v16.
98
- - Updated `actions/checkout` to v2.
99
- - Updated `actions/setup-node` to v2.
100
- - Simplify config with the [`npm install-test`](https://docs.npmjs.com/cli/v7/commands/npm-install-test) command.
101
- - Don’t specify the `CI` environment variable as it’s set by default.
102
- - Removed `npm-debug.log` from the `.gitignore` file as npm [v4.2.0](https://github.com/npm/npm/releases/tag/v4.2.0)+ doesn’t create it in the current working directory.
103
- - Updated the EditorConfig URL.
104
- - Updated the package `keywords` field.
105
- - More specific package `main` field path.
106
- - Simplified JSDoc related package scripts now that [`jsdoc-md`](https://npm.im/jsdoc-md) v10 automatically generates a Prettier formatted readme.
107
- - Added a package `test:jsdoc` script that checks the readme API docs are up to date with the source JSDoc.
108
- - Refactored private constants from exports of a single module to individual modules.
109
- - Fixed test name and comment typos.
110
- - Updated external URLs in docs.
111
- - Prettier format for a JSDoc code example.
112
- - Updated a `GraphQLUpload` code example to use [`@graphql-tools/schema`](https://npm.im/@graphql-tools/schema) instead of [`graphql-tools`](https://npm.im/graphql-tools).
113
- - Removed from the readme the notice that the package was previously published as [`apollo-upload-server`](https://npm.im/apollo-upload-server).
114
- - Simplified the readme “Setup” and “Support” sections.
115
-
116
- ## 11.0.0
117
-
118
- ### Major
119
-
120
- - Updated Node.js support to `^10.13.0 || ^12.0.0 || >= 13.7.0`.
121
- - Added a [package `exports` field](https://nodejs.org/api/esm.html#esm_package_entry_points) with [conditional exports](https://nodejs.org/api/esm.html#esm_conditional_exports) to support native ESM in Node.js and keep internal code private, [whilst avoiding the dual package hazard](https://nodejs.org/api/esm.html#esm_approach_1_use_an_es_module_wrapper). Published files have been reorganized, so previously undocumented deep imports will need to be rewritten according to the newly documented paths.
122
- - Updated dev dependencies, some of which require newer Node.js versions than previously supported.
123
-
124
- ### Patch
125
-
126
- - Updated the [`graphql`](https://npm.im/graphql) peer dependency to `0.13.1 - 15`, fixing [#200](https://github.com/jaydenseric/graphql-upload/issues/200) via [#201](https://github.com/jaydenseric/graphql-upload/pull/201).
127
- - Updated Prettier related package scripts.
128
- - Configured Prettier option `semi` to the default, `true`.
129
- - Ensure GitHub Actions run on pull request.
130
- - Also run GitHub Actions with Node.js v14.
131
- - Fixed the `ignoreStream` function tests for Node.js v14 with a new `CountReadableStream` test helper, fixing [#209](https://github.com/jaydenseric/graphql-upload/issues/209).
132
- - Minor JSDoc wording tweak for consistency.
133
- - Mention [`Promise.allSettled`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/allSettled) in the readme “Tips” section.
134
- - Updated MDN Web Docs links.
135
-
136
- ## 10.0.0
137
-
138
- ### Major
139
-
140
- - Updated Node.js support from v8.10+ to v10+, as earlier versions have reached end-of-life.
141
- - Updated the [`fs-capacitor`](https://npm.im/fs-capacitor) dependency to v6, which now requires Node.js v10+, via [#179](https://github.com/jaydenseric/graphql-upload/pull/179).
142
- - Updated dev dependencies, some of which now require Node.js v10+.
143
- - Replaced the [`tap`](https://npm.im/tap) dev dependency with [`test-director`](https://npm.im/test-director), [`coverage-node`](https://npm.im/coverage-node), and [`hard-rejection`](https://npm.im/hard-rejection) to improve the dev experience and reduce the dev install size by ~75.7 MB. These new dev dependencies require Node.js v10+.
144
- - Reorganized files. This is only a breaking change for projects using undocumented deep imports.
145
- - Removed now redundant Node.js version compatibility logic in the `processRequest` function.
146
- - The `processRequest` function now places references to instances of the now exported and documented `Upload` class in the GraphQL operation for the `GraphQLUpload` scalar to derive its value, and the `GraphQLUpload` scalar now throws a `GraphQLError` when it parses an invalid value, fixing [#175](https://github.com/jaydenseric/graphql-upload/issues/175) via [#181](https://github.com/jaydenseric/graphql-upload/pull/181).
147
- - The `GraphQLUpload` scalar `parseLiteral` and `serialize` methods now throw `GraphQLError` (instead of `Error`) instances, with tweaked messages.
148
-
149
- ### Minor
150
-
151
- - The `createReadStream` function in resolved file uploads now accepts options to configure the encoding and high water mark, fixing [#177](https://github.com/jaydenseric/graphql-upload/issues/177) via [#179](https://github.com/jaydenseric/graphql-upload/pull/179).
152
-
153
- ### Patch
154
-
155
- - Removed the now redundant [`eslint-plugin-import-order-alphabetical`](https://npm.im/eslint-plugin-import-order-alphabetical) and [`express-async-handler`](https://npm.im/express-async-handler) dev dependencies.
156
- - Stop using [`husky`](https://npm.im/husky) and [`lint-staged`](https://npm.im/lint-staged).
157
- - Use [`isobject`](https://npm.im/isobject) for checking if values are enumerable, non-array objects.
158
- - Tests have been massively reorganized, refactored, and improved.
159
- - Test the `GraphQLUpload` scalar.
160
- - Test the `ignoreStream` function.
161
- - Moved the `Upload` class to its own file.
162
- - Added JSDoc for the `Upload` class instance property `file`.
163
- - Test the `Upload` class.
164
- - Improved JSDoc `FileUpload` typedef description.
165
- - Removed now redundant `eslint-disable-next-line` comments.
166
- - Use strict mode for scripts.
167
-
168
- ## 9.0.0
169
-
170
- ### Major
171
-
172
- - Updated Node.js support from v8.5+ to v8.10+, to match what the [`eslint`](https://npm.im/eslint) dev dependency now supports. This is unlikely to be a breaking change for the published package.
173
- - Removed the `Upload` scalar promise resolved `stream` property that has been deprecated since v7, along with associated tests.
174
- - ESM is no longer published, due to CJS/ESM compatibility issues across recent Node.js versions, via [#169](https://github.com/jaydenseric/graphql-upload/pull/169).
175
- - The file structure and non-index file exports have changed. This should only affect projects using undocumented deep imports.
176
-
177
- ### Minor
178
-
179
- - Updated the [`fs-capacitor`](https://npm.im/fs-capacitor) dependency to v4 to support Node.js v13, making required changes to the source and tests, via [#166](https://github.com/jaydenseric/graphql-upload/pull/166).
180
- - JSDoc comments are now included in the published code.
181
- - Several anonymous functions have been named, for better error stack traces.
182
- - Setup [GitHub Sponsors funding](https://github.com/sponsors/jaydenseric):
183
- - Added `.github/funding.yml` to display a sponsor button in GitHub.
184
- - Added a `package.json` `funding` field to enable npm CLI funding features.
185
-
186
- ### Patch
187
-
188
- - Updated dev dependencies.
189
- - Removed the `.nycrc.json` file:
190
- - [`tap`](https://npm.im/tap) now ignores test files by default.
191
- - The `lib/test-helpers` directory is now ignored using [`tap`](https://npm.im/tap) CLI arguments due to [tapjs/node-tap#612](https://github.com/tapjs/node-tap/issues/612).
192
- - Removed the `esm` and `mjs` package tags; they will be added back once native ESM is properly supported.
193
- - Updated JSDoc code examples to use CJS instead of ESM, as native ESM is not yet properly supported.
194
- - No longer test [`fs-capacitor`](https://npm.im/fs-capacitor) implementation details such as temp file creation and cleanup.
195
- - Commented the reasons for several `istanbul ignore next` comments.
196
-
197
- ## 8.1.0
198
-
199
- ### Minor
200
-
201
- - `processRequest` now throws an appropriate error when a multipart field value exceeds the configured size limit, fixing [#159](https://github.com/jaydenseric/graphql-upload/issues/159).
202
- - When the file size limit is exceeded, mention how many bytes the limit is in the stream error message.
203
- - Added a new `processRequest` option to the `graphqlUploadExpress` and `graphqlUploadKoa` middleware, for improved testing without mocks or spies which are difficult to achieve with ESM.
204
-
205
- ### Patch
206
-
207
- - Updated dependencies.
208
- - Due to updated dependencies: Lint fixes, removed redundant `eslint-disable-next-line` comments, and regenerated the readme.
209
- - Documented [`koa-graphql`](https://npm.im/koa-graphql) as known to be compatible, via [#156](https://github.com/jaydenseric/graphql-upload/pull/156).
210
- - Fixed a readme typo, via [#161](https://github.com/jaydenseric/graphql-upload/pull/161).
211
- - Use GitHub Actions instead of Travis for CI.
212
- - Removed `package-lock.json` from `.gitignore` and `.prettierignore`, as it’s disabled in `.npmrc` anyway.
213
- - New file structure.
214
- - Explicitly defined main exports (instead of using `export * from`) to prevent accidental public exposure of internal APIs.
215
- - Moved JSDoc typedefs into the index main entry file, alphabetically sorted.
216
- - Nicer Browserslist query syntax.
217
- - Replaced the `isObject` helper with a smarter and tested `isEnumerableObject`.
218
- - Removed the `isString` helper.
219
- - Enforced 100% code coverage for tests, and improved `processRequest` internals and tests (including a new test using vanilla Node.js HTTP), fixing [#130](https://github.com/jaydenseric/graphql-upload/issues/130) via [#162](https://github.com/jaydenseric/graphql-upload/pull/162).
220
- - Removed a workaround from the `startServer` test helper.
221
- - Added a new `ProcessRequestFunction` JSDoc type, and applied it to `processRequest`.
222
- - Renamed the `UploadOptions` JSDoc type to `ProcessRequestOptions`.
223
- - Misc. documentation improvements.
224
-
225
- ## 8.0.7
226
-
227
- ### Patch
228
-
229
- - Updated dependencies.
230
- - Handle invalid object paths in `map` multipart field entries, fixing [#154](https://github.com/jaydenseric/graphql-upload/issues/154).
231
- - Import `WriteStream` from [`fs-capacitor`](https://npm.im/fs-capacitor) as a named rather than default import.
232
-
233
- ## 8.0.6
234
-
235
- ### Patch
236
-
237
- - Updated dependencies.
238
- - Allow batched operations again, fixing [#142](https://github.com/jaydenseric/graphql-upload/issues/142).
239
- - Simplify tests by writing JSON as strings instead of using `JSON.stringify`.
240
- - Use async middleware with [`express-async-handler`](https://npm.im/express-async-handler) for Express tests.
241
- - Removed unintended `maxFiles` config in certain tests.
242
- - Added the Open Graph image design to the logo Sketch file.
243
-
244
- ## 8.0.5
245
-
246
- ### Patch
247
-
248
- - Updated dependencies.
249
- - Handle invalid types in multipart fields and respond with meaningful HTTP 400 errors, via [#139](https://github.com/jaydenseric/graphql-upload/pull/139):
250
- - Invalid `operations` type.
251
- - Invalid `map` type.
252
- - Invalid `map` entry type.
253
- - Invalid `map` entry array item type.
254
- - Additionally test current Node.js v8 and v10 versions with Travis.
255
- - Reduced the size of the published `package.json` by moving dev tool config to files. This also prevents editor extensions such as Prettier and ESLint from detecting config and attempting to operate when opening package files installed in `node_modules`.
256
- - Removed the [`watch`](https://npm.im/watch) dev dependency and `watch` script.
257
- - Simplified the `prepublishOnly` script.
258
- - Change to the `classic` TAP reporter for tests.
259
- - Add [`apollo-server-koa`](https://npm.im/apollo-server-koa) and [`apollo-server-express`](https://npm.im/apollo-server-express) back to the compatible environments list in the readme, now that they use the current version of this package.
260
-
261
- ## 8.0.4
262
-
263
- ### Patch
264
-
265
- - Updated the [`fs-capacitor`](https://npm.im/fs-capacitor) dependency to v2, fixing [#131](https://github.com/jaydenseric/graphql-upload/issues/131) via [#132](https://github.com/jaydenseric/graphql-upload/pull/132).
266
-
267
- ## 8.0.3
268
-
269
- ### Patch
270
-
271
- - Updated dependencies. The `busboy` update contains [a bug fix for `.pipe()` on file streams](https://github.com/mscdex/busboy/issues/188).
272
- - Use [jsDelivr](https://jsdelivr.com) for the readme logo instead of [RawGit](https://rawgit.com) as they are shutting down.
273
-
274
- ## 8.0.2
275
-
276
- ### Patch
277
-
278
- - Updated dev dependencies.
279
- - Fixed hanging when a request with a large payload has an “immediate” error, such as a malformed request, fixing [#123](https://github.com/jaydenseric/graphql-upload/issues/123) via [#124](https://github.com/jaydenseric/graphql-upload/pull/124).
280
- - Moved JSDoc type definitions to the end of files to make it easier to open to the code.
281
-
282
- ## 8.0.1
283
-
284
- ### Patch
285
-
286
- - Updated dev dependencies.
287
- - Removed the package `module` field. Webpack by default resolves extensionless paths the same way Node.js in `--experimental-modules` mode does; `.mjs` files are preferred. Tools misconfigured or unable to resolve `.mjs` can get confused when `module` points to an `.mjs` ESM file and they attempt to resolve named imports from `.js` CJS files.
288
- - Updated package scripts and config for the new [`husky`](https://npm.im/husky) version.
289
- - Added a package `browserslist` field with the target Node.js version for [`@babel/preset-env`](https://npm.im/@babel/preset-env) and removed related config from `babel.config.js`.
290
- - Tests now log if the environment is CJS or ESM (`--experimental-modules`) and the `NODE_ENV`.
291
- - Fixed broken readme API documentation links.
292
-
293
- ## 8.0.0
294
-
295
- ### Major
296
-
297
- - New naming that drops “apollo” to reflect the independent and universal nature of the project, fixing [#68](https://github.com/jaydenseric/apollo-upload-server/issues/68):
298
-
299
- - Changed the package name from [`apollo-upload-server`](https://npm.im/apollo-upload-server) to [`graphql-upload`](https://npm.im/graphql-upload).
300
- - Renamed `apolloUploadKoa` to `graphqlUploadKoa`.
301
- - Renamed `apolloUploadExpress` to `graphqlUploadExpress`.
302
-
303
- To migrate you project from `apollo-upload-server@7.1.0` to `graphql-upload@8.0.0`:
304
-
305
- 1. Run `npm uninstall apollo-upload-server`.
306
- 2. Run `npm install graphql-upload`.
307
- 3. Find and replace:
308
- - `apolloUploadKoa` → `graphqlUploadKoa`.
309
- - `apolloUploadExpress` → `graphqlUploadExpress`.
310
-
311
- ### Patch
312
-
313
- - Updated dependencies.
314
- - New project logo.
315
-
316
- ## 7.1.0
317
-
318
- ### Minor
319
-
320
- - Support [`graphql`](https://npm.im/graphql) v14.
321
-
322
- ### Patch
323
-
324
- - Updated dev dependencies.
325
-
326
- ## 7.0.0
327
-
328
- ### Major
329
-
330
- - The `processRequest` function now requires a [`http.ServerResponse`](https://nodejs.org/api/http.html#http_class_http_serverresponse) instance as its second argument.
331
- - Replaced the previously exported error classes with [`http-errors`](https://npm.im/http-errors) and snapshot tested error details, via [#105](https://github.com/jaydenseric/apollo-upload-server/pull/105).
332
- - No longer exporting the `SPEC_URL` constant.
333
-
334
- ### Minor
335
-
336
- - `Upload` scalar promises now resolve with a `createReadStream` method instead of a `stream` property, via [#92](https://github.com/jaydenseric/apollo-upload-server/pull/92).
337
- - Accessing an `Upload` scalar promise resolved `stream` property results in a deprecation warning that recommends using `createReadStream` instead. It will be removed in a future release. Via [#107](https://github.com/jaydenseric/apollo-upload-server/pull/107).
338
- - An `Upload` scalar variable can now be used by multiple resolvers, via [#92](https://github.com/jaydenseric/apollo-upload-server/pull/92).
339
- - Multiple `Upload` scalar variables can now use the same multipart data, via [#92](https://github.com/jaydenseric/apollo-upload-server/pull/92).
340
- - Malformed requests containing invalid JSON for `operations` or `map` multipart fields cause an appropriate error with a `400` status instead of crashing the process, relating to [#81](https://github.com/jaydenseric/apollo-upload-server/pull/81) and [#95](https://github.com/jaydenseric/apollo-upload-server/issues/95).
341
- - Malformed requests missing `operations`, `map` and files, or just `map` and files, cause an appropriate error with a `400` status instead of hanging, fixing [#96](https://github.com/jaydenseric/apollo-upload-server/issues/96).
342
- - Tweaked `GraphQLUpload` scalar description to remove details about how it resolves on the server as they are irrelevant to API users.
343
- - Tweaked `GraphQLUpload` scalar error messages.
344
-
345
- ### Patch
346
-
347
- - Updated dev dependencies.
348
- - Removed the [`npm-run-all`](https://npm.im/npm-run-all) dev dependency and made scripts and tests sync for easier debugging, at the cost of slightly longer build times.
349
- - Explicitly set `processRequest` default options instead of relying on [`busboy`](https://npm.im/busboy) defaults.
350
- - Better organized project file structure.
351
- - Configured Prettier to lint `.yml` files.
352
- - Ensure the readme Travis build status badge only tracks `master` branch.
353
-
354
- ## 6.0.0-alpha.1
355
-
356
- Big thanks to new collaborator [@mike-marcacci](https://github.com/mike-marcacci) for his help solving tricky bugs and edge-cases!
357
-
358
- ### Major
359
-
360
- - Updated Node.js support from v6.10+ to v8.5+ for [native ESM](https://github.com/nodejs/node/blob/master/doc/changelogs/CHANGELOG_V8.md#8.5.0), [object rest/spread properties](https://node.green#ES2018-features-object-rest-spread-properties), and [async functions](https://node.green#ES2017-features-async-functions).
361
- - Removed the [`@babel/runtime`](https://npm.im/@babel/runtime) dependency and config.
362
- - Fixed [#45](https://github.com/jaydenseric/apollo-upload-server/issues/45), [#77](https://github.com/jaydenseric/apollo-upload-server/issues/77) and [#83](https://github.com/jaydenseric/apollo-upload-server/issues/83) via [#81](https://github.com/jaydenseric/apollo-upload-server/pull/81):
363
- - Add `error` event listeners to file streams to prevent server crashes on aborted requests or parser errors.
364
- - Use [`fs-capacitor`](https://npm.im/fs-capacitor) to ensure the server doesn’t hang if an upload `await` is out of order, or is never consumed.
365
-
366
- ### Minor
367
-
368
- - Refactored package scripts to use `prepare` to support installation via Git (e.g. `npm install jaydenseric/apollo-upload-server`).
369
-
370
- ### Patch
371
-
372
- - Updated dependencies.
373
- - Use single instead of double typographic quotes in error messages.
374
- - Use `babel.config.js` instead of `.babelrc.js`.
375
- - Enabled `shippedProposals` in [`@babel/preset-env`](https://npm.im/@babel/preset-env) config.
376
- - Improved testing:
377
- - Use [`tap`](https://npm.im/tap) instead of [`ava`](https://npm.im/ava). Tests no longer transpile on the fly, are faster and AVA no longer dictates the Babel version.
378
- - Tests run against the actual dist `.mjs` and `.js` files in native ESM (`--experimental-modules`) and CJS environments.
379
- - Removed `get-port` dev dependency.
380
- - Added Express tests.
381
- - Test middleware error response status codes.
382
- - Test behavior of aborted HTTP requests.
383
- - Test that the app can respond if an upload is not handled.
384
- - Test files to upload are created in context, rather than using arbitrary project files, via [#89](https://github.com/jaydenseric/apollo-upload-server/pull/89).
385
- - Improved `package.json` scripts:
386
- - Leveraged `npm-run-all` more for parallelism and reduced noise.
387
- - Removed the clean script `rimraf` dev dependency in favour of native `rm -rf`. Leaner and faster; we only support \*nix now for contributing anyway.
388
- - No longer use `cross-env`; contributors with Windows may setup and use a Bash shell.
389
- - Renamed the `ESM` environment variable to `BABEL_ESM` to be more specific.
390
- - Removed linting fix scripts.
391
- - Linting included in the test script; Travis CI will fail PR's with lint errors.
392
- - Custom watch script.
393
- - Improved ESLint config:
394
- - Simplified ESLint config with [`eslint-config-env`](https://npm.im/eslint-config-env).
395
- - Removed redundant [`eslint-plugin-ava`](https://npm.im/eslint-plugin-ava) dev dependency and config.
396
- - Undo overriding ESLint ignoring dotfiles by default as there are none now.
397
- - Use `.prettierignore` to leave `package.json` formatting to npm.
398
- - Tweaked package `description` and `keywords`.
399
- - Compact package `repository` field.
400
- - Improved documentation.
401
- - Readme badge changes to deal with [shields.io](https://shields.io) unreliability:
402
- - Use the official Travis build status badge.
403
- - Use [Badgen](https://badgen.net) for the npm version badge.
404
- - Removed the licence badge. The licence can be found in `package.json` and rarely changes.
405
- - Removed the Github issues and stars badges. The readme is most viewed on Github anyway.
406
- - Changelog version entries now have “Major”, “Minor” and “Patch” subheadings.
407
-
408
- ## 5.0.0
409
-
410
- ### Major
411
-
412
- - [`graphql`](https://npm.im/graphql) peer dependency range updated to `^0.13.1` for native ESM support via `.mjs`. It’s a breaking change despite being a semver patch.
413
-
414
- ### Patch
415
-
416
- - Updated dependencies.
417
- - More robust npm scripts, with the ability to watch builds and tests together.
418
- - Fixed missing dev dependency for fetching in tests.
419
- - Use [`eslint-plugin-ava`](https://github.com/avajs/eslint-plugin-ava).
420
- - HTTPS `package.json` author URL.
421
- - New readme logo URL that doesn’t need to be updated every version.
422
-
423
- ## 4.0.2
424
-
425
- ### Patch
426
-
427
- - Temporary solution for importing CommonJS in `.mjs`, fixing reopened [#40](https://github.com/jaydenseric/apollo-upload-server/issues/40).
428
-
429
- ## 4.0.1
430
-
431
- ### Patch
432
-
433
- - Correct imports for vanilla Node.js `--experimental-modules` and `.mjs` support, fixing [#40](https://github.com/jaydenseric/apollo-upload-server/issues/40).
434
-
435
- ## 4.0.0
436
-
437
- ### Patch
438
-
439
- - Updated dependencies.
440
- - Simplified npm scripts.
441
- - Readme updates:
442
- - Documented [`Blob`](https://developer.mozilla.org/en-US/docs/Web/API/Blob) types, via [#39](https://github.com/jaydenseric/apollo-upload-server/pull/39).
443
- - Explained how to use `processRequest` for custom middleware.
444
- - Improved usage instructions.
445
- - Display oldest supported Node.js version.
446
- - Misc. tweaks including a simpler heading structure.
447
-
448
- ## 4.0.0-alpha.3
449
-
450
- ### Minor
451
-
452
- - Updated peer dependencies to support `graphql@0.12`, via [#36](https://github.com/jaydenseric/apollo-upload-server/pull/36).
453
-
454
- ### Patch
455
-
456
- - Updated dependencies.
457
-
458
- ## 4.0.0-alpha.2
459
-
460
- ### Minor
461
-
462
- - Transpile and polyfill for Node.js v6.10+ (down from v7.6+) to [support AWS Lambda](https://docs.aws.amazon.com/lambda/latest/dg/current-supported-versions.html), fixing [#33](https://github.com/jaydenseric/apollo-upload-server/issues/33).
463
- - Modular project structure that works better for native ESM.
464
- - Added tests.
465
- - Set up Travis to test using the latest stable Node.js version and the oldest supported in `package.json` `engines` (v6.10).
466
- - Added a Travis readme badge.
467
- - Improved error handling, fixing [#26](https://github.com/jaydenseric/apollo-upload-server/issues/26):
468
- - Custom errors are thrown or emitted with meaningful messages that are exported so consumers can use `instanceof` with them.
469
- - Where it makes sense, errors cause relevant HTTP status codes to be set in middleware.
470
- - [Misordered multipart fields](https://github.com/jaydenseric/graphql-multipart-request-spec) cause `processRequest` to throw `MapBeforeOperationsUploadError` and `FilesBeforeMapUploadError` errors in middleware.
471
- - The `map` field provided by the client is used to naively check the `maxFiles` option is not exceeded for a speedy `MaxFilesUploadError` error in middleware. The real number of files parsed is checked too, incase the request is malformed.
472
- - If files are missing from the request the `scalar Upload` promises reject with a `FileMissingUploadError` error.
473
- - Already if a file exceeds the `maxFileSize` option the file is truncated, the stream emits a `limit` event and `stream.truncated === true`. Now an `error` event is also emitted with a `MaxFileSizeUploadError`.
474
- - Aborting requests from the client causes `scalar Upload` promises to reject with a `UploadPromiseDisconnectUploadError` error for file upload streams that have not yet been parsed. For streams being parsed an `error` event is emitted with an `FileStreamDisconnectUploadError` error and `stream.truncated === true`. It is up to consumers to cleanup aborted streams in their resolvers.
475
-
476
- ### Patch
477
-
478
- - Updated dependencies.
479
- - Smarter Babel config with `.babelrc.js`.
480
- - Refactor to use fewer Busboy event listeners.
481
-
482
- ## 4.0.0-alpha.1
483
-
484
- ### Major
485
-
486
- - New API to support the [GraphQL multipart request spec v2.0.0-alpha.2](https://github.com/jaydenseric/graphql-multipart-request-spec/releases/tag/v2.0.0-alpha.2). Files no longer upload to the filesystem; [readable streams](https://nodejs.org/api/stream.html#stream_readable_streams) are used in resolvers instead. Fixes [#13](https://github.com/jaydenseric/apollo-upload-server/issues/13) via [#22](https://github.com/jaydenseric/apollo-upload-server/pull/22).
487
- - Export a new `Upload` scalar type to use in place of the old `Upload` input type. It represents a file upload promise that resolves an object containing `stream`, `filename`, `mimetype` and `encoding`.
488
- - Deprecated the `uploadDir` middleware option.
489
- - `graphql` is now a peer dependency.
490
-
491
- ### Minor
492
-
493
- - Added new `maxFieldSize`, `maxFileSize` and `maxFiles` middleware options.
494
-
495
- ### Patch
496
-
497
- - Middleware are now arrow functions.
498
-
499
- ## 3.0.0
500
-
501
- ### Major
502
-
503
- - Updated Node.js support from v6.4+ to v7.6+.
504
- - Express middleware now passes on errors instead of blocking, via [#20](https://github.com/jaydenseric/apollo-upload-server/pull/20).
505
-
506
- ### Patch
507
-
508
- - Using Babel directly, dropping Rollup.
509
- - New directory structure for compiled files.
510
- - Module files now have `.mjs` extension.
511
- - No longer publish the `src` directory.
512
- - No more sourcemaps.
513
- - Use an arrow function for the Koa middleware, to match the Express middleware.
514
- - Compiled code is now prettier.
515
- - Prettier markdown files.
516
- - Updated package keywords.
517
- - Updated an Apollo documentation link in the changelog.
518
- - Readme improvements:
519
- - Added links to badges.
520
- - Removed the inspiration links; they are less relevant to the evolved codebase.
521
- - Fixed an Apollo link.
522
- - Replaced example resolver code with a link to the [Apollo upload examples](https://github.com/jaydenseric/apollo-upload-examples).
523
-
524
- ## 2.0.4
525
-
526
- ### Patch
527
-
528
- - Updated dependencies.
529
- - Readme tweaks including a new license badge.
530
-
531
- ## 2.0.3
532
-
533
- ### Patch
534
-
535
- - Updated dependencies.
536
- - Removed `package-lock.json`. Lockfiles are [not recommended](https://github.com/sindresorhus/ama/issues/479#issuecomment-310661514) for packages.
537
- - Moved Babel config out of `package.json` to prevent issues when consumers run Babel over `node_modules`.
538
- - Readme tweaks and fixes:
539
- - Renamed the `File` input type `Upload` for clarity.
540
- - Wording and formatting improvements.
541
- - Covered React Native.
542
- - Documented custom middleware.
543
-
544
- ## 2.0.2
545
-
546
- ### Patch
547
-
548
- - Updated dependencies.
549
- - Added a changelog.
550
- - Dropped Yarn in favor of npm@5. Removed `yarn.lock` and updated install instructions.
551
- - Set targeted Node version as a string for `babel-preset-env`.
552
- - New ESLint config. Dropped [Standard Style](https://standardjs.com) and began using [Prettier](https://github.com/prettier/eslint-plugin-prettier).
553
- - Using [lint-staged](https://github.com/okonet/lint-staged) to ensure contributors don't commit lint errors.
554
- - Removed `build:watch` script. Use `npm run build -- --watch` directly.
555
-
556
- ## 2.0.1
557
-
558
- ### Patch
559
-
560
- - Updated dependencies.
561
- - Support regular requests from clients other than apollo-upload-client again, fixing [#4](https://github.com/jaydenseric/apollo-upload-server/issues/4).
562
- - Removed incorrect commas from example GraphQL input type.
563
-
564
- ## 2.0.0
565
-
566
- ### Major
567
-
568
- - Support `apollo-upload-client` v3 and [query batching](https://apollographql.com/docs/apollo-server/requests#batching).
569
-
570
- ### Patch
571
-
572
- - Clearer package description.
573
- - Use [Standard Style](https://standardjs.com) instead of ESLint directly.
574
-
575
- ## 1.1.0
576
-
577
- ### Minor
578
-
579
- - Exporting a new helper function for processing requests. It can be used to create custom middleware, or middleware for unsupported routers.
580
- - Exporting new Koa middleware.
581
- - Upload directory is ensured on every request now. While slightly less efficient, it prevents major errors when if it is deleted while the server is running.
582
-
583
- ### Patch
584
-
585
- - Updated dependencies.
586
- - Documented npm install as well as Yarn.
587
- - Typo fix in the readme.
588
-
589
- ## 1.0.2
590
-
591
- ### Patch
592
-
593
- - Fixed broken Github deep links in the readme.
594
- - Readme rewording.
595
- - Simplified `package.json` description.
596
-
597
- ## 1.0.1
598
-
599
- ### Patch
600
-
601
- - Added missing metadata to `package.json`.
602
- - Added a link to apollographql/graphql-server in the readme.
603
-
604
- ## 1.0.0
605
-
606
- Initial release.