diff --git a/koa-static/koa-static-tests.ts b/koa-static/koa-static-tests.ts new file mode 100644 index 0000000000..bc77286fee --- /dev/null +++ b/koa-static/koa-static-tests.ts @@ -0,0 +1,11 @@ +/// +/// + +import * as Koa from "koa"; +import serve = require("koa-static"); + +const app = new Koa(); + +app.use(serve('.',{index:false,defer:false})); + +app.listen(80) \ No newline at end of file diff --git a/koa-static/koa-static.d.ts b/koa-static/koa-static.d.ts new file mode 100644 index 0000000000..4b95eca3be --- /dev/null +++ b/koa-static/koa-static.d.ts @@ -0,0 +1,51 @@ +// Type definitions for koa-static v2.x +// Project: https://github.com/koajs/static +// Definitions by: Jerry Chin +// Definitions: https://github.com/hellopao/DefinitelyTyped + +/* =================== USAGE =================== + + import serve = require("koa-static"); + var Koa = require('koa'); + + var app = new Koa(); + app.use(serve(".")); + + =============================================== */ + +/// + +declare module "koa-static" { + + import * as Koa from "koa"; + + function serve(root: string, opts?: { + + /** + * Default file name, defaults to 'index.html' + */ + index?: boolean | string; + + /** + * If true, serves after return next(),allowing any downstream middleware to respond first. + */ + defer?: boolean; + + /** + * Browser cache max-age in milliseconds. defaults to 0 + */ + maxage?: number; + + /** + * 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; + }): { (ctx: Koa.Context, next?: () => any): any }; + + export = serve; +}