1 | import { IncomingMessage, ServerResponse } from 'http';
|
2 |
|
3 | interface SourceData {
|
4 | mtime?: Date;
|
5 | maxAge?: number;
|
6 | getData: () => Promise<Buffer>;
|
7 | }
|
8 | declare type Source = (src: string) => Promise<SourceData>;
|
9 | declare type SourceFactory = (options?: any) => Source;
|
10 |
|
11 | interface ImageMeta {
|
12 | width: number;
|
13 | height: number;
|
14 | type: string;
|
15 | mimeType: string;
|
16 | }
|
17 | interface IPXInputOptions {
|
18 | source?: string;
|
19 | modifiers?: Record<string, string>;
|
20 | }
|
21 | interface IPXCTX {
|
22 | sources: Record<string, Source>;
|
23 | }
|
24 | declare type IPX = (id: string, opts?: IPXInputOptions) => {
|
25 | src: () => Promise<SourceData>;
|
26 | data: () => Promise<{
|
27 | data: Buffer;
|
28 | meta: ImageMeta;
|
29 | format: string;
|
30 | }>;
|
31 | };
|
32 | interface IPXOptions {
|
33 | dir?: false | string;
|
34 | domains?: false | string[];
|
35 | alias: Record<string, string>;
|
36 | sharp?: {
|
37 | [key: string]: any;
|
38 | };
|
39 | }
|
40 | declare function createIPX(userOptions: Partial<IPXOptions>): IPX;
|
41 |
|
42 | interface IPXHRequest {
|
43 | url: string;
|
44 | headers?: Record<string, string>;
|
45 | }
|
46 | interface IPXHResponse {
|
47 | statusCode: number;
|
48 | statusMessage: string;
|
49 | headers: Record<string, string>;
|
50 | data: any;
|
51 | }
|
52 | declare function handleRequest(req: IPXHRequest, ipx: IPX): Promise<IPXHResponse>;
|
53 | declare function createIPXMiddleware(ipx: IPX): (req: IncomingMessage, res: ServerResponse) => void;
|
54 |
|
55 | export { IPX, IPXCTX, IPXHRequest, IPXHResponse, IPXInputOptions, IPXOptions, ImageMeta, Source, SourceData, SourceFactory, createIPX, createIPXMiddleware, handleRequest };
|