Add type definitions for koa-send.

This commit is contained in:
Peter Safranek
2016-10-12 23:09:38 -07:00
parent ec9eb4b28c
commit d34cfd7426
2 changed files with 50 additions and 0 deletions
+23
View File
@@ -0,0 +1,23 @@
/// <reference path="../koa/koa.d.ts" />
/// <reference path="koa-send.d.ts" />
import * as Koa from "koa";
import * as send from "koa-send";
const app = new Koa();
app.use(async (ctx: Koa.Context) => {
const path: string = await send(ctx, 'stimpy.html');
});
app.use(async (ctx: Koa.Context) => {
await send(ctx, 'stimpy.html', {
root: '../static-files',
index: 'index.html',
maxAge: 10,
hidden: true,
format: true,
gzip: true,
setHeaders: () => {},
});
});
+27
View File
@@ -0,0 +1,27 @@
// Type definitions for koa-send v3.x
// Project: https://github.com/koajs/send
// Definitions by: Peter Safranek <https://github.com/pe8ter>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
/// <reference path="../koa/koa.d.ts" />
declare module "koa-send" {
import * as Koa from "koa";
interface ISendOptions {
root?: string;
index?: string;
maxAge?: number;
hidden?: boolean;
format?: boolean;
gzip?: boolean;
setHeaders?: Function;
}
function send(ctx: Koa.Context, path: string, opts?: ISendOptions): Promise<string>;
namespace send {}
export = send;
}