From 62e1efd40289dc0e43e48a8da3f7f67081aba509 Mon Sep 17 00:00:00 2001 From: hellopao Date: Wed, 6 Apr 2016 10:31:21 +0800 Subject: [PATCH] add definitions for koa-favicon --- koa-favicon/koa-favicon-tests.ts | 11 ++++++++++ koa-favicon/koa-favicon.d.ts | 35 ++++++++++++++++++++++++++++++++ 2 files changed, 46 insertions(+) create mode 100644 koa-favicon/koa-favicon-tests.ts create mode 100644 koa-favicon/koa-favicon.d.ts diff --git a/koa-favicon/koa-favicon-tests.ts b/koa-favicon/koa-favicon-tests.ts new file mode 100644 index 0000000000..5f2e0ac3f0 --- /dev/null +++ b/koa-favicon/koa-favicon-tests.ts @@ -0,0 +1,11 @@ +/// +/// + +import * as Koa from "koa"; +import favicon = require("koa-favicon"); + +const app = new Koa(); + +app.use(favicon(__dirname + "/public/favicon.ico")); + +app.listen(80) \ No newline at end of file diff --git a/koa-favicon/koa-favicon.d.ts b/koa-favicon/koa-favicon.d.ts new file mode 100644 index 0000000000..618683fc76 --- /dev/null +++ b/koa-favicon/koa-favicon.d.ts @@ -0,0 +1,35 @@ +// Type definitions for koa-favicon v2.x +// Project: https://github.com/koajs/favicon +// Definitions by: Jerry Chin +// Definitions: https://github.com/hellopao/DefinitelyTyped + +/* =================== USAGE =================== + + import favicon = require("koa-favicon"); + var Koa = require('koa'); + + var app = new Koa(); + app.use(favicon(__dirname + '/public/favicon.ico')); + + =============================================== */ + +/// + +declare module "koa-favicon" { + + import * as Koa from "koa"; + + /** + * Returns a middleware serving the favicon found on the given path. + */ + function favicon(path: string, options?: { + + /** + * cache-control max-age directive in ms, defaulting to 1 day. + */ + maxage?: number; + + }): { (ctx: Koa.Context, next?: () => any): any }; + + export = favicon; +}