graphql-upload-nextjs 1.0.0 → 2.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.
Files changed (5) hide show
  1. package/LICENSE +21 -21
  2. package/README.md +311 -364
  3. package/index.d.ts +37 -23
  4. package/index.js +216 -110
  5. package/package.json +71 -62
package/index.d.ts CHANGED
@@ -1,22 +1,37 @@
1
- import { GraphQLScalarType, GraphQLError } from 'graphql';
2
- import { NextResponse } from 'next/server.js';
3
1
  import type { GraphQLResponse } from '@apollo/server';
2
+ import { GraphQLScalarType } from 'graphql';
3
+ import { NextResponse } from 'next/server.js';
4
+ /** Represents a processed file with metadata and stream access. */
4
5
  export interface File {
5
6
  createReadStream: () => NodeJS.ReadableStream;
6
7
  encoding: string;
7
- fileName: string;
8
8
  fileSize: number;
9
- mimeType: string;
10
- }
11
- export interface FileStream extends FormDataFile {
12
- stream: () => Promise<NodeJS.ReadableStream>;
9
+ filename: string;
10
+ mimetype: string;
13
11
  }
12
+ /** Raw file entry extracted from multipart FormData. */
14
13
  export interface FormDataFile {
15
14
  lastModified: number;
16
15
  name: string;
17
16
  size: number;
18
17
  type: string;
19
18
  }
19
+ /** Extends FormDataFile with a stream method for reading file contents. */
20
+ export interface FileStream extends FormDataFile {
21
+ stream: () => ReadableStream;
22
+ }
23
+ /** Minimal request interface compatible with Next.js and Web API requests. */
24
+ export interface MinimalRequest {
25
+ formData: () => Promise<FormData>;
26
+ headers: {
27
+ get: (name: string) => string | null;
28
+ };
29
+ }
30
+ /** Parameters for Apollo Server's executeOperation method. */
31
+ interface ServerExecuteOperationParams {
32
+ query: string;
33
+ variables: Record<string, unknown>;
34
+ }
20
35
  /**
21
36
  * Represents an instance of a file upload.
22
37
  * Holds a promise that resolves with the file details once processed.
@@ -28,29 +43,28 @@ export declare class Upload {
28
43
  resolve: (file: File) => void;
29
44
  constructor();
30
45
  }
31
- export declare const GraphQLUpload: GraphQLScalarType<Promise<File> | GraphQLError, never>;
32
- export declare function streamToBuffer(stream: NodeJS.ReadableStream): Promise<Buffer>;
46
+ /** Custom GraphQL scalar type for handling file uploads. */
47
+ export declare const GraphQLUpload: GraphQLScalarType<Promise<File>, never>;
48
+ /** Converts a Buffer into a Node.js readable stream. */
33
49
  export declare function bufferToStream(buffer: Buffer): NodeJS.ReadableStream;
50
+ /** Parses JSON for the operations field. Accepts objects or arrays (for batching per spec). */
51
+ export declare function parseOperationsJSON(input: string): Record<string, unknown> | Record<string, unknown>[];
52
+ /** Parses and validates a JSON string, ensuring it resolves to a non-null object (rejects arrays). */
34
53
  export declare function sanitizeAndValidateJSON(input: string): unknown;
35
- interface ServerExecuteOperationParams {
36
- query: string;
37
- variables: Record<string, unknown>;
38
- }
39
- export interface MinimalRequest {
40
- formData: () => Promise<FormData>;
41
- headers: {
42
- get: (name: string) => string | null;
43
- };
44
- }
45
- /**
46
- * Processes a GraphQL multipart request with file uploads.
47
- */
54
+ /** Sets a value at a dot-notation path in a nested object, creating intermediate containers as needed. */
55
+ export declare function setValueAtPath(obj: Record<string, unknown>, path: string, value: unknown): void;
56
+ /** Converts a Node.js readable stream into a Buffer by collecting all chunks. */
57
+ export declare function streamToBuffer(stream: NodeJS.ReadableStream): Promise<Buffer>;
58
+ /** Validates that each map entry is an array of string paths. */
59
+ export declare function validateMap(map: Record<string, unknown>): string | null;
60
+ /** Processes a GraphQL multipart request with file uploads. Supports batching per the spec. */
48
61
  export declare function uploadProcess<TContext extends Record<string, unknown>>(request: MinimalRequest, contextValueInput: TContext, server: {
49
62
  executeOperation: (params: ServerExecuteOperationParams, context: {
50
63
  contextValue: TContext;
51
64
  }) => Promise<GraphQLResponse<TContext>>;
52
65
  }, settings?: {
53
66
  allowedTypes?: string[];
67
+ maxFiles?: number;
54
68
  maxFileSize?: number;
55
- }): Promise<NextResponse<any>>;
69
+ }): Promise<NextResponse>;
56
70
  export {};
package/index.js CHANGED
@@ -1,7 +1,8 @@
1
- import { GraphQLScalarType, GraphQLError } from 'graphql';
2
- import { NextResponse } from 'next/server.js';
3
1
  import { fileTypeFromBuffer } from 'file-type';
2
+ import { GraphQLError, GraphQLScalarType } from 'graphql';
4
3
  import { isText } from 'istextorbinary';
4
+ import { NextResponse } from 'next/server.js';
5
+ import { Readable } from 'stream';
5
6
  /**
6
7
  * Represents an instance of a file upload.
7
8
  * Holds a promise that resolves with the file details once processed.
@@ -22,176 +23,281 @@ export class Upload {
22
23
  this.promise.catch(() => { });
23
24
  }
24
25
  }
26
+ /** Custom GraphQL scalar type for handling file uploads. */
25
27
  export const GraphQLUpload = new GraphQLScalarType({
26
28
  description: 'The Upload scalar type represents a file upload.',
27
29
  name: 'Upload',
28
- parseLiteral(node) { throw new GraphQLError('Upload literal unsupported.', { nodes: node }); },
29
- parseValue(value) { return value instanceof Upload ? value.promise : new GraphQLError('Upload value invalid.'); },
30
- serialize() { throw new GraphQLError('Upload serialization unsupported.'); }
30
+ parseLiteral(node) {
31
+ throw new GraphQLError('Upload literal unsupported.', { nodes: node });
32
+ },
33
+ parseValue(value) {
34
+ if (value instanceof Upload)
35
+ return value.promise;
36
+ throw new GraphQLError('Upload value invalid.');
37
+ },
38
+ serialize() {
39
+ throw new GraphQLError('Upload serialization unsupported.');
40
+ },
31
41
  });
42
+ /** Converts a Buffer into a Node.js readable stream. */
43
+ export function bufferToStream(buffer) {
44
+ const stream = new Readable();
45
+ stream.push(buffer);
46
+ stream.push(null);
47
+ return stream;
48
+ }
49
+ /** Collects a GraphQL response into a serializable result object. */
50
+ async function collectResponse(response) {
51
+ if (response.body.kind === 'single') {
52
+ return response.body.singleResult;
53
+ }
54
+ if (response.body.kind === 'incremental') {
55
+ const { initialResult, subsequentResults } = response.body;
56
+ const collected = [];
57
+ for await (const result of subsequentResults) {
58
+ collected.push(result);
59
+ }
60
+ return { initialResult, subsequentResults: collected };
61
+ }
62
+ return { errors: [{ message: 'Unexpected server response format' }] };
63
+ }
64
+ /** Extracts File entries from multipart FormData. */
32
65
  async function extractFiles(formData) {
33
66
  const files = {};
34
- for (const [key, value] of Array.from(formData.entries())) {
67
+ for (const [key, value] of formData.entries()) {
35
68
  if (value instanceof globalThis.File) {
36
69
  files[key] = value;
37
70
  }
38
71
  }
39
72
  return files;
40
73
  }
41
- export async function streamToBuffer(stream) {
42
- const chunks = [];
43
- for await (const chunk of stream) {
44
- if (Buffer.isBuffer(chunk)) {
45
- chunks.push(chunk);
46
- }
47
- else if (typeof chunk === 'string') {
48
- chunks.push(Buffer.from(chunk));
74
+ /** Parses JSON for the operations field. Accepts objects or arrays (for batching per spec). */
75
+ export function parseOperationsJSON(input) {
76
+ let result;
77
+ try {
78
+ result = JSON.parse(input);
79
+ }
80
+ catch {
81
+ throw new Error('Invalid JSON in the operations multipart field.');
82
+ }
83
+ if (typeof result !== 'object' || result === null) {
84
+ throw new Error('Invalid type for the operations multipart field.');
85
+ }
86
+ return result;
87
+ }
88
+ /**
89
+ * Processes a file from FormData, detects its MIME type via magic bytes,
90
+ * and returns a resolved Upload instance with streaming file access.
91
+ */
92
+ async function processUpload(file, allowedTypes) {
93
+ if (!file.name || typeof file.size !== 'number' || !file.type) {
94
+ throw new Error('Invalid file properties: name, size, or type is missing or invalid.');
95
+ }
96
+ const blob = file;
97
+ // Only read the first 4100 bytes for MIME type detection via magic bytes.
98
+ // This avoids buffering the entire file into memory.
99
+ const DETECTION_BYTES = 4100;
100
+ const headerBuffer = Buffer.from(await blob.slice(0, DETECTION_BYTES).arrayBuffer());
101
+ const fileTypeInfo = await fileTypeFromBuffer(new Uint8Array(headerBuffer.buffer, headerBuffer.byteOffset, headerBuffer.byteLength));
102
+ let mimetype = file.type;
103
+ if (fileTypeInfo) {
104
+ mimetype = fileTypeInfo.mime;
105
+ }
106
+ else {
107
+ try {
108
+ if (await isText(file.name, headerBuffer)) {
109
+ mimetype = 'text/plain';
110
+ }
49
111
  }
50
- else {
51
- chunks.push(Buffer.from(chunk));
112
+ catch {
113
+ // Fallback: isText detection failed, proceeding with original mimetype from FormData.
52
114
  }
53
115
  }
54
- return Buffer.concat(chunks);
55
- }
56
- export function bufferToStream(buffer) {
57
- const { Readable } = require('stream');
58
- const stream = new Readable();
59
- stream.push(buffer);
60
- stream.push(null);
61
- return stream;
116
+ if (allowedTypes && !allowedTypes.includes(mimetype)) {
117
+ throw new Error(`File type ${mimetype} is not allowed. Allowed types: ${allowedTypes.join(', ')}`);
118
+ }
119
+ const upload = new Upload();
120
+ upload.resolve({
121
+ createReadStream: () => Readable.fromWeb(blob.stream()),
122
+ encoding: 'binary',
123
+ fileSize: file.size,
124
+ filename: file.name,
125
+ mimetype,
126
+ });
127
+ return upload;
62
128
  }
129
+ /** Parses and validates a JSON string, ensuring it resolves to a non-null object (rejects arrays). */
63
130
  export function sanitizeAndValidateJSON(input) {
131
+ let result;
64
132
  try {
65
- const result = JSON.parse(input);
66
- if (typeof result !== 'object' || result === null) {
67
- throw new Error('Invalid JSON structure: not an object.');
68
- }
69
- return result;
133
+ result = JSON.parse(input);
70
134
  }
71
135
  catch (error) {
72
136
  throw new Error(`Invalid JSON input: ${error.message}`);
73
137
  }
138
+ if (typeof result !== 'object' || result === null || Array.isArray(result)) {
139
+ throw new Error('Invalid JSON structure: expected a non-null object.');
140
+ }
141
+ return result;
74
142
  }
75
- function setValueAtPath(obj, path, value) {
143
+ /** Dangerous property names that could lead to prototype pollution. */
144
+ const BLOCKED_KEYS = new Set(['__proto__', 'constructor', 'prototype']);
145
+ /** Sets a value at a dot-notation path in a nested object, creating intermediate containers as needed. */
146
+ export function setValueAtPath(obj, path, value) {
76
147
  const keys = path.split('.');
77
148
  let current = obj;
78
149
  for (let i = 0; i < keys.length - 1; i++) {
79
150
  const key = keys[i];
151
+ if (BLOCKED_KEYS.has(key)) {
152
+ throw new Error(`Invalid path segment: '${key}' is not allowed.`);
153
+ }
80
154
  const nextKeyIsArrayIndex = /^\d+$/.test(keys[i + 1]);
81
- if (!current[key] || typeof current[key] !== (nextKeyIsArrayIndex ? 'object' : 'object')) {
82
- if (current[key] && ((nextKeyIsArrayIndex && !Array.isArray(current[key])) || (!nextKeyIsArrayIndex && Array.isArray(current[key])))) {
83
- // Path conflict, overwriting.
84
- }
155
+ if (!current[key] ||
156
+ typeof current[key] !== 'object' ||
157
+ (nextKeyIsArrayIndex && !Array.isArray(current[key])) ||
158
+ (!nextKeyIsArrayIndex && Array.isArray(current[key]))) {
85
159
  current[key] = nextKeyIsArrayIndex ? [] : {};
86
160
  }
87
161
  current = current[key];
88
162
  }
89
- current[keys[keys.length - 1]] = value;
90
- }
91
- async function processUpload(file, allowedTypes) {
92
- if (!file.name || typeof file.size !== 'number' || !file.type) {
93
- throw new Error('Invalid file properties: name, size, or type is missing or invalid.');
94
- }
95
- const stream = await file.stream();
96
- const buffer = await streamToBuffer(stream);
97
- const uint8ArrayForFileType = new Uint8Array(buffer.buffer, buffer.byteOffset, buffer.byteLength);
98
- const fileTypeInfo = await fileTypeFromBuffer(uint8ArrayForFileType);
99
- let mimeType = file.type;
100
- if (fileTypeInfo) {
101
- mimeType = fileTypeInfo.mime;
163
+ const finalKey = keys[keys.length - 1];
164
+ if (BLOCKED_KEYS.has(finalKey)) {
165
+ throw new Error(`Invalid path segment: '${finalKey}' is not allowed.`);
102
166
  }
103
- else {
104
- try {
105
- const isTextResult = await isText(file.name, buffer);
106
- if (isTextResult === true) {
107
- mimeType = 'text/plain';
108
- }
167
+ current[finalKey] = value;
168
+ }
169
+ /** Converts a Node.js readable stream into a Buffer by collecting all chunks. */
170
+ export async function streamToBuffer(stream) {
171
+ const chunks = [];
172
+ for await (const chunk of stream) {
173
+ if (Buffer.isBuffer(chunk)) {
174
+ chunks.push(chunk);
109
175
  }
110
- catch (err) {
111
- // isText check failed, proceed with original mimeType
176
+ else if (typeof chunk === 'string') {
177
+ chunks.push(Buffer.from(chunk));
178
+ }
179
+ else {
180
+ chunks.push(Buffer.from(chunk));
112
181
  }
113
182
  }
114
- if (allowedTypes && !allowedTypes.includes(mimeType)) {
115
- throw new Error(`File type ${mimeType} is not allowed. Allowed types: ${allowedTypes.join(', ')}`);
183
+ return Buffer.concat(chunks);
184
+ }
185
+ /** Validates that each map entry is an array of string paths. */
186
+ export function validateMap(map) {
187
+ for (const [key, paths] of Object.entries(map)) {
188
+ if (!Array.isArray(paths)) {
189
+ return `Invalid type for map entry '${key}': expected an array of paths.`;
190
+ }
191
+ for (const p of paths) {
192
+ if (typeof p !== 'string') {
193
+ return `Invalid path in map entry '${key}': expected string.`;
194
+ }
195
+ }
116
196
  }
117
- const upload = new Upload();
118
- upload.resolve({
119
- fileSize: file.size,
120
- fileName: file.name,
121
- mimeType: mimeType,
122
- encoding: 'binary',
123
- createReadStream: () => bufferToStream(buffer)
124
- });
125
- return upload;
197
+ return null;
126
198
  }
127
- /**
128
- * Processes a GraphQL multipart request with file uploads.
129
- */
199
+ /** Processes a GraphQL multipart request with file uploads. Supports batching per the spec. */
130
200
  export async function uploadProcess(request, contextValueInput, server, settings) {
131
201
  try {
132
202
  const formData = await request.formData();
133
203
  const files = await extractFiles(formData);
134
- const mapString = formData.get('map');
135
- const operationsString = formData.get('operations');
136
- if (!mapString || !operationsString) {
137
- throw new Error('Missing map or operations in form data.');
204
+ const mapRaw = formData.get('map');
205
+ const operationsRaw = formData.get('operations');
206
+ if (!mapRaw || !operationsRaw || typeof mapRaw !== 'string' || typeof operationsRaw !== 'string') {
207
+ return NextResponse.json({ errors: [{ message: 'Missing or invalid map/operations in form data.' }] }, { status: 400 });
138
208
  }
139
- const map = sanitizeAndValidateJSON(mapString);
140
- const operations = sanitizeAndValidateJSON(operationsString);
141
- const fileProcessingPromises = [];
142
- if (!operations.variables) {
143
- operations.variables = {};
209
+ const mapString = mapRaw;
210
+ const operationsString = operationsRaw;
211
+ // Parse and validate the map field (must be an object, not array).
212
+ let map;
213
+ try {
214
+ map = sanitizeAndValidateJSON(mapString);
215
+ }
216
+ catch {
217
+ return NextResponse.json({ errors: [{ message: 'Invalid JSON in the map multipart field.' }] }, { status: 400 });
218
+ }
219
+ const mapError = validateMap(map);
220
+ if (mapError) {
221
+ return NextResponse.json({ errors: [{ message: mapError }] }, { status: 400 });
222
+ }
223
+ // Parse the operations field (object or array for batching).
224
+ let parsedOperations;
225
+ try {
226
+ parsedOperations = parseOperationsJSON(operationsString);
227
+ }
228
+ catch {
229
+ return NextResponse.json({ errors: [{ message: 'Invalid JSON in the operations multipart field.' }] }, { status: 400 });
230
+ }
231
+ // Check maxFiles limit.
232
+ if (settings?.maxFiles && Object.keys(map).length > settings.maxFiles) {
233
+ return NextResponse.json({ errors: [{ message: `${settings.maxFiles} max file uploads exceeded.` }] }, { status: 413 });
234
+ }
235
+ // Normalize operations into a keyed object for path resolution.
236
+ // Single: paths are "variables.file" → use the operation object directly.
237
+ // Batch: paths are "0.variables.file" → use indices as keys in a wrapper object.
238
+ const isBatch = Array.isArray(parsedOperations);
239
+ let operationsRoot;
240
+ if (isBatch) {
241
+ operationsRoot = {};
242
+ for (let i = 0; i < parsedOperations.length; i++) {
243
+ const op = parsedOperations[i];
244
+ if (!op.variables)
245
+ op.variables = {};
246
+ operationsRoot[String(i)] = op;
247
+ }
248
+ }
249
+ else {
250
+ const singleOp = parsedOperations;
251
+ if (!singleOp.variables)
252
+ singleOp.variables = {};
253
+ operationsRoot = singleOp;
144
254
  }
255
+ // Process files and resolve Upload instances at mapped paths.
256
+ const fileProcessingPromises = [];
145
257
  for (const fileKeyInMap of Object.keys(map)) {
146
258
  const file = files[fileKeyInMap];
147
259
  if (!file) {
148
- map[fileKeyInMap].forEach(path => {
149
- setValueAtPath(operations, path, null);
150
- });
260
+ // Per spec: reject Upload promise when file is missing from the request.
261
+ for (const filePath of map[fileKeyInMap]) {
262
+ const missingUpload = new Upload();
263
+ missingUpload.reject(new Error('File missing in the request.'));
264
+ setValueAtPath(operationsRoot, filePath, missingUpload);
265
+ }
151
266
  continue;
152
267
  }
153
268
  if (settings?.maxFileSize && file.size > settings.maxFileSize) {
154
- return NextResponse.json({ errors: [{ message: `File ${file.name} size is too large. Maximum allowed size is ${settings.maxFileSize / (1024 * 1024)}MB.` }] }, { status: 413 });
269
+ return NextResponse.json({ errors: [{ message: `File ${file.name} size is too large. Maximum allowed size is ${(settings.maxFileSize / (1024 * 1024)).toFixed(2)}MB.` }] }, { status: 413 });
155
270
  }
156
271
  const variablePaths = map[fileKeyInMap];
157
272
  const filePromise = processUpload(file, settings?.allowedTypes)
158
273
  .then(uploadInstance => {
159
- variablePaths.forEach(path => {
160
- setValueAtPath(operations, path, uploadInstance);
161
- });
274
+ for (const filePath of variablePaths) {
275
+ setValueAtPath(operationsRoot, filePath, uploadInstance);
276
+ }
162
277
  })
163
- .catch(error => {
164
- variablePaths.forEach(path => {
278
+ .catch((error) => {
279
+ for (const filePath of variablePaths) {
165
280
  const uploadError = new Upload();
166
281
  uploadError.reject(new Error(`Failed to process file ${file.name}: ${error.message}`));
167
- setValueAtPath(operations, path, uploadError);
168
- });
169
- throw new Error(`Failed to process file ${file.name}: ${error.message}`);
282
+ setValueAtPath(operationsRoot, filePath, uploadError);
283
+ }
170
284
  });
171
285
  fileProcessingPromises.push(filePromise);
172
286
  }
173
- try {
174
- await Promise.all(fileProcessingPromises);
175
- }
176
- catch (processingError) {
177
- // Individual file processing errors are handled by rejecting Upload.promise.
178
- }
179
- const response = await server.executeOperation({ query: operations.query, variables: operations.variables }, { contextValue: contextValueInput });
180
- if (response.body.kind === 'single') {
181
- return NextResponse.json(response.body.singleResult);
182
- }
183
- else if (response.body.kind === 'incremental') {
184
- const { initialResult, subsequentResults } = response.body;
185
- const collectedSubsequentResults = [];
186
- for await (const result of subsequentResults) {
187
- collectedSubsequentResults.push(result);
287
+ await Promise.all(fileProcessingPromises);
288
+ // Execute operations and collect results.
289
+ if (isBatch) {
290
+ const results = [];
291
+ const sortedKeys = Object.keys(operationsRoot).sort((a, b) => Number(a) - Number(b));
292
+ for (const key of sortedKeys) {
293
+ const op = operationsRoot[key];
294
+ const response = await server.executeOperation({ query: op.query, variables: op.variables || {} }, { contextValue: contextValueInput });
295
+ results.push(await collectResponse(response));
188
296
  }
189
- return NextResponse.json({
190
- initialResult,
191
- subsequentResults: collectedSubsequentResults,
192
- });
297
+ return NextResponse.json(results);
193
298
  }
194
- return NextResponse.json({ errors: [{ message: 'Unexpected server response format' }] }, { status: 500 });
299
+ const response = await server.executeOperation({ query: operationsRoot.query, variables: operationsRoot.variables }, { contextValue: contextValueInput });
300
+ return NextResponse.json(await collectResponse(response));
195
301
  }
196
302
  catch (error) {
197
303
  const errorMessage = error instanceof Error ? error.message : 'Unknown error during upload processing.';
package/package.json CHANGED
@@ -1,62 +1,71 @@
1
- {
2
- "author": {
3
- "email": "lafittemehdy@gmail.com",
4
- "name": "Lafitte Mehdy"
5
- },
6
- "bugs": {
7
- "url": "https://github.com/lafittemehdy/graphql-upload-nextjs/issues"
8
- },
9
- "dependencies": {
10
- "@apollo/server": "^5.0.0",
11
- "file-type": "^21.0.0",
12
- "graphql": "^16.11.0",
13
- "istextorbinary": "^9.5.0",
14
- "next": "^15.5.3"
15
- },
16
- "description": "The middleware and Upload scalar in this package enable GraphQL multipart requests (file uploads via queries and mutations) in your Apollo Server Next.js integration.",
17
- "devDependencies": {
18
- "@types/jest": "^30.0.0",
19
- "@types/node": "^24.5.2",
20
- "cross-env": "^7.0.3",
21
- "jest": "^30.1.3",
22
- "nodemon": "^3.1.10",
23
- "ts-jest": "^29.4.4",
24
- "typescript": "^5.9.2",
25
- "undici": "^7.16.0"
26
- },
27
- "files": [
28
- "LICENSE",
29
- "README.md",
30
- "index.d.ts",
31
- "index.js"
32
- ],
33
- "homepage": "https://github.com/lafittemehdy/graphql-upload-nextjs#readme",
34
- "keywords": [
35
- "Apollo Server",
36
- "File streaming",
37
- "File upload",
38
- "GraphQL file upload",
39
- "GraphQL resolver",
40
- "GraphQL upload",
41
- "GraphQL",
42
- "Next.js integration",
43
- "Next.js",
44
- "Server-side upload"
45
- ],
46
- "license": "MIT",
47
- "main": "index.js",
48
- "name": "graphql-upload-nextjs",
49
- "repository": {
50
- "type": "git",
51
- "url": "git+https://github.com/lafittemehdy/graphql-upload-nextjs.git"
52
- },
53
- "scripts": {
54
- "dev": "tsc -w | nodemon index.js",
55
- "start": "tsc && node index.js",
56
- "build": "tsc",
57
- "test": "echo \"Error: no test specified\" && exit 1"
58
- },
59
- "type": "module",
60
- "types": "index.d.ts",
61
- "version": "1.0.0"
62
- }
1
+ {
2
+ "author": {
3
+ "email": "lafittemehdy@gmail.com",
4
+ "name": "Lafitte Mehdy"
5
+ },
6
+ "bugs": {
7
+ "url": "https://github.com/lafittemehdy/graphql-upload-nextjs/issues"
8
+ },
9
+ "dependencies": {
10
+ "@apollo/server": "^5.4.0",
11
+ "file-type": "^21.3.3",
12
+ "graphql": "^16.13.1",
13
+ "istextorbinary": "^9.5.0",
14
+ "next": "^16.1.7"
15
+ },
16
+ "description": "The middleware and Upload scalar in this package enable GraphQL multipart requests (file uploads via queries and mutations) in your Apollo Server Next.js integration.",
17
+ "devDependencies": {
18
+ "@types/jest": "^30.0.0",
19
+ "@types/node": "^25.5.0",
20
+ "husky": "^9.1.7",
21
+ "jest": "^30.3.0",
22
+ "nodemon": "^3.1.14",
23
+ "ts-jest": "^29.4.6",
24
+ "typescript": "^5.9.3",
25
+ "undici": "^7.24.4"
26
+ },
27
+ "files": [
28
+ "LICENSE",
29
+ "README.md",
30
+ "index.d.ts",
31
+ "index.js"
32
+ ],
33
+ "engines": {
34
+ "node": ">=22.0.0"
35
+ },
36
+ "homepage": "https://github.com/lafittemehdy/graphql-upload-nextjs#readme",
37
+ "keywords": [
38
+ "Apollo Server",
39
+ "File streaming",
40
+ "File upload",
41
+ "GraphQL file upload",
42
+ "GraphQL resolver",
43
+ "GraphQL upload",
44
+ "GraphQL",
45
+ "Next.js integration",
46
+ "Next.js",
47
+ "Server-side upload"
48
+ ],
49
+ "license": "MIT",
50
+ "main": "index.js",
51
+ "name": "graphql-upload-nextjs",
52
+ "publishConfig": {
53
+ "access": "public",
54
+ "provenance": true
55
+ },
56
+ "repository": {
57
+ "type": "git",
58
+ "url": "git+https://github.com/lafittemehdy/graphql-upload-nextjs.git"
59
+ },
60
+ "scripts": {
61
+ "build": "tsc",
62
+ "dev": "tsc -w | nodemon index.js",
63
+ "prepublishOnly": "npm run build && npm test",
64
+ "start": "tsc && node index.js",
65
+ "test": "jest",
66
+ "prepare": "husky"
67
+ },
68
+ "type": "module",
69
+ "types": "index.d.ts",
70
+ "version": "2.0.0"
71
+ }