mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-10-04 06:47:03 +00:00
Merge pull request #22075 from tlaziuk/koa-static
[koa-static] upgrade to v4.0
This commit is contained in:
Vendored
+1
-1
@@ -29,7 +29,7 @@ declare namespace send {
|
||||
/** 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;
|
||||
index?: string | false;
|
||||
/** 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). */
|
||||
|
||||
Vendored
+12
-32
@@ -1,7 +1,8 @@
|
||||
// Type definitions for koa-static 3.0
|
||||
// Type definitions for koa-static 4.0
|
||||
// Project: https://github.com/koajs/static
|
||||
// Definitions by: Jerry Chin <https://github.com/hellopao>
|
||||
// Definitions: https://github.com/hellopao/DefinitelyTyped
|
||||
// Tomek Łaziuk <https://github.com/tlaziuk>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.3
|
||||
|
||||
/* =================== USAGE ===================
|
||||
@@ -14,38 +15,17 @@
|
||||
|
||||
=============================================== */
|
||||
|
||||
import * as Koa from "koa";
|
||||
import { Middleware } from "koa";
|
||||
|
||||
declare function serve(root: string, opts?: {
|
||||
/**
|
||||
* Default file name, defaults to 'index.html'
|
||||
*/
|
||||
index?: boolean | string;
|
||||
import { SendOptions } from "koa-send";
|
||||
|
||||
/**
|
||||
* If true, serves after return next(),allowing any downstream middleware to respond first.
|
||||
*/
|
||||
defer?: boolean;
|
||||
declare function serve(root: string, opts?: serve.Options): Middleware;
|
||||
|
||||
/**
|
||||
* Browser cache max-age in milliseconds. defaults to 0
|
||||
*/
|
||||
maxage?: number;
|
||||
declare namespace serve {
|
||||
interface Options extends SendOptions {
|
||||
/** If true, serves after return next(), allowing any downstream middleware to respond first. */
|
||||
defer?: boolean;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Allow transfer of hidden files. defaults to false
|
||||
*/
|
||||
hidden?: boolean;
|
||||
|
||||
/**
|
||||
* 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 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[];
|
||||
}): Koa.Middleware;
|
||||
declare namespace serve {}
|
||||
export = serve;
|
||||
|
||||
@@ -4,9 +4,9 @@ import serve = require("koa-static");
|
||||
const app = new Koa();
|
||||
|
||||
app.use(serve('.', {
|
||||
index: false,
|
||||
defer: false,
|
||||
extensions: ['html']
|
||||
index: false,
|
||||
defer: false,
|
||||
extensions: ['html'],
|
||||
}));
|
||||
|
||||
app.listen(80);
|
||||
|
||||
Reference in New Issue
Block a user