4.0.8 • Published 6 months ago

@types/multer-gridfs-storage v4.0.8

Weekly downloads
1,393
License
MIT
Repository
github
Last release
6 months ago

Installation

npm install --save @types/multer-gridfs-storage

Summary

This package contains type definitions for multer-gridfs-storage (https://github.com/devconcept/multer-gridfs-storage).

Details

Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/multer-gridfs-storage/v1.

index.d.ts

// Type definitions for multer-gridfs-storage 1.1
// Project: https://github.com/devconcept/multer-gridfs-storage
// Definitions by: devconcept <https://github.com/devconcept>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// Minimum TypeScript Version: 4.1

import { EventEmitter } from 'events';
import { Express } from 'express';
import * as Multer from 'multer';
import { Grid } from 'gridfs-stream';

type logConfig = 'file' | 'all';

interface StorageLog {
    message: string;
    extra: any;
}

type NodeCb<T> = (err: Error | null, value: T | null) => void;

type ConfigFn<T> = (req: Express.Request, file: Express.Multer.File, cb: T) => void;

// TODO: PR and add this interface to the mongodb types
interface GridFile {
    _id: any;
    filename: string;
    contentType: string;
    length: number;
    chunkSize: number;
    uploadDate: Date;
    aliases: any;
    metadata: any;
    md5: string;
}

interface MulterGfsOptions {
    filename?: ConfigFn<NodeCb<string>> | undefined;
    identifier?: ConfigFn<NodeCb<any>> | undefined;
    metadata?: ConfigFn<NodeCb<any>> | undefined;
    chunkSize?: number | ConfigFn<NodeCb<number>> | undefined;
    root?: string | ConfigFn<NodeCb<string>> | undefined;
    log?: boolean | NodeCb<StorageLog> | undefined;
    logLevel?: logConfig | undefined;
}

declare class MulterGridfsStorage extends EventEmitter implements Multer.StorageEngine {
    constructor(settings: MulterGridfsStorage.UrlStorageOptions | MulterGridfsStorage.GfsStorageOptions);

    _handleFile(req: Express.Request, file: Express.Multer.File, callback: (error?: any, info?: Express.Multer.File) => void): void;

    _removeFile(req: Express.Request, file: Express.Multer.File, callback: (error: Error) => void): void;
}

declare namespace MulterGridfsStorage {
    interface UrlStorageOptions extends MulterGfsOptions {
        url: string;
    }

    interface GfsStorageOptions extends MulterGfsOptions {
        gfs: Promise<Grid> | Grid;
    }
}

// Merge multer's file declaration with ours
declare global {
    namespace Express {
        namespace Multer {
            interface File {
                filename: string;
                metadata: any;
                id: any;
                grid: GridFile;
                size: number;
            }
        }
    }
}

export = MulterGridfsStorage;

Additional Details

Credits

These definitions were written by devconcept.

3.1.11

6 months ago

3.1.10

7 months ago

3.1.9

8 months ago

4.0.7

7 months ago

4.0.6

8 months ago

4.0.8

6 months ago

2.0.11

7 months ago

2.0.12

6 months ago

2.0.10

8 months ago

1.1.12

7 months ago

1.1.11

8 months ago

1.1.13

6 months ago

2.0.9

2 years ago

1.1.10

2 years ago

3.1.8

2 years ago

4.0.5

2 years ago

4.0.4

3 years ago

1.1.9

3 years ago

2.0.8

3 years ago

3.1.7

3 years ago

4.0.3

3 years ago

3.1.6

3 years ago

4.0.2

3 years ago

1.1.8

4 years ago

1.1.7

4 years ago

2.0.7

4 years ago

3.1.5

4 years ago

4.0.1

4 years ago

3.1.4

5 years ago

4.0.0

5 years ago

1.1.6

5 years ago

2.0.6

5 years ago

3.1.3

5 years ago

1.1.5

5 years ago

2.0.5

5 years ago

3.1.2

5 years ago

3.1.1

6 years ago

3.1.0

6 years ago

2.0.4

6 years ago

2.0.3

6 years ago

2.0.2

7 years ago

1.1.4

7 years ago

1.1.3

7 years ago

2.0.1

7 years ago

2.0.0

7 years ago

1.1.2

7 years ago

1.1.1

7 years ago

1.1.0

7 years ago