add definitions for koa-static

This commit is contained in:
hellopao
2016-04-01 15:34:54 +08:00
parent 667df4b7a7
commit 921f3276fe
2 changed files with 62 additions and 0 deletions

View File

@@ -0,0 +1,11 @@
/// <reference path="../koa/koa.d.ts" />
/// <reference path="koa-static.d.ts" />
import * as Koa from "koa";
import serve = require("koa-static");
const app = new Koa();
app.use(serve('.',{index:false,defer:false}));
app.listen(80)

51
koa-static/koa-static.d.ts vendored Normal file
View File

@@ -0,0 +1,51 @@
// Type definitions for koa-static v2.x
// Project: https://github.com/koajs/static
// Definitions by: Jerry Chin <https://github.com/hellopao/>
// Definitions: https://github.com/hellopao/DefinitelyTyped
/* =================== USAGE ===================
import serve = require("koa-static");
var Koa = require('koa');
var app = new Koa();
app.use(serve("."));
=============================================== */
/// <reference path="../koa/koa.d.ts" />
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;
}