UNPKG

1.14 kBTypeScriptView Raw
1import { Request as ERequest, Response as EResponse } from "express";
2import AsyncResponse from "./async.response";
3/**
4 * This interface defines the currently available options for files.
5 */
6export interface FileOptions {
7 width: number;
8 height?: number;
9}
10/**
11 * Generation of a File response.
12 */
13export default class FileResponse extends AsyncResponse {
14 private readonly path;
15 private _contentType?;
16 private _fileName;
17 private _options?;
18 constructor(path: string);
19 /**
20 * Set the content type of the response.
21 * @param value the content type
22 */
23 contentType: string;
24 /**
25 * Set the name of the file to download
26 * @param value the name of the file
27 */
28 fileName: string;
29 /**
30 * Set the file options, to correctly generate the response.
31 * @param value the FileOptions
32 */
33 options: FileOptions;
34 private download;
35 /**
36 * Generation of the response.
37 * This method can eventually perform some transformation on output if a
38 * FileOptions was specified.
39 */
40 asyncResponse(_: ERequest, res: EResponse): Promise<void>;
41}