mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-12-04 04:01:52 +00:00
Add type definitions for koa-send.
This commit is contained in:
@@ -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: () => {},
|
||||
});
|
||||
});
|
||||
Vendored
+27
@@ -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;
|
||||
}
|
||||
Reference in New Issue
Block a user