graphql-upload-ts
Version:
TypeScript-first middleware and Upload scalar for GraphQL multipart requests (file uploads) with support for Apollo Server, Express, Koa, and more.
30 lines • 1.47 kB
TypeScript
import type { UploadOptions } from './process-request';
export interface ValidationResult {
isValid: boolean;
error?: string;
}
/**
* Maximum size for non-file form fields (in bytes).
* This applies to text fields like 'operations' and 'map' in GraphQL multipart requests.
* These fields contain JSON data (query, variables, and file mappings).
* Default: 1MB - sufficient for large GraphQL queries and variable sets.
*/
export declare const DEFAULT_MAX_FIELD_SIZE = 1000000;
/**
* Maximum size for uploaded files (in bytes).
* This applies to the actual binary file content being uploaded.
* Default: 5MB - a reasonable limit for most web applications.
* Can be overridden per request for larger files (videos, high-res images, etc.).
*/
export declare const DEFAULT_MAX_FILE_SIZE = 5000000;
/**
* Maximum number of files that can be uploaded in a single request.
* Default: Infinity - no limit on the number of files.
* Should be set to a reasonable number in production to prevent abuse.
*/
export declare const DEFAULT_MAX_FILES: number;
export declare function validateOptions(options?: UploadOptions): UploadOptions;
export declare function validateMimeType(mimetype: string, allowedTypes?: string[]): ValidationResult;
export declare function validateFileExtension(filename: string, allowedExtensions?: string[]): ValidationResult;
export declare function sanitizeFilename(filename: string): string;
//# sourceMappingURL=validation.d.ts.map