From a1ffa9ffba45514a52117e167c597a30fbc0136a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomek=20=C5=81aziuk?= Date: Tue, 5 Dec 2017 08:24:01 +0100 Subject: [PATCH] koa-send v4,1 --- types/koa-send/index.d.ts | 51 +++++++++++++++++++++++++++------------ 1 file changed, 36 insertions(+), 15 deletions(-) diff --git a/types/koa-send/index.d.ts b/types/koa-send/index.d.ts index a15f5b688d..e1cdfce1ef 100644 --- a/types/koa-send/index.d.ts +++ b/types/koa-send/index.d.ts @@ -1,24 +1,45 @@ -// Type definitions for koa-send v3.3 +// Type definitions for koa-send 4.1 // Project: https://github.com/koajs/send // Definitions by: Peter Safranek +// Tomek Łaziuk // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.3 -import * as Koa from 'koa'; +import { + Context, +} from "koa"; -interface ISendOptions { - root?: string; - index?: string; - maxAge?: number; - hidden?: boolean; - format?: boolean; - gzip?: boolean; - setHeaders?: Function; - extensions?: string[]; +import { + Stats, +} from "fs"; + + +declare function send(ctx: Context, path: string, opts?: send.IOpts): Promise; + +declare namespace send { + interface IOpts { + /** Browser cache max-age in milliseconds. (defaults to 0) */ + maxage?: number; + maxAge?: IOpts["maxage"]; + /** Tell the browser the resource is immutable and can be cached indefinitely. (defaults to false) */ + immutable?: boolean; + /** Allow transfer of hidden files. (defaults to false) */ + hidden?: boolean; + /** Root directory to restrict file access. (defaults to '') */ + root?: string; + /** Name of the index file to serve automatically when visiting the root location. (defaults to none) */ + index?: string; + /** Try to serve the gzipped version of a file automatically when gzip is supported by a client and if the requested file with .gz extension exists. (defaults to true). */ + gzip?: boolean; + /** Try to serve the brotli version of a file automatically when brotli is supported by a client and if the requested file with .br extension exists. (defaults to true). */ + brotli?: boolean; + /** If not false (defaults to true), format the path to serve static file servers and not require a trailing slash for directories, so that you can do both /directory and /directory/. */ + format?: boolean; + /** Function to set custom headers on response. */ + setHeaders?: (res: Context["res"], path: string, stats: Stats) => any; + /** Try to match extensions from passed array to search for file when no extension is sufficed in URL. First found is served. (defaults to false) */ + extensions?: string[] | false; + } } -declare function send(ctx: Koa.Context, path: string, opts?: ISendOptions): Promise; - -declare namespace send {} - export = send;