mirror of
https://github.com/zhigang1992/DefinitelyTyped.git
synced 2026-05-16 11:02:11 +08:00
add definitions for koa-static
This commit is contained in:
11
koa-static/koa-static-tests.ts
Normal file
11
koa-static/koa-static-tests.ts
Normal 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
51
koa-static/koa-static.d.ts
vendored
Normal 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;
|
||||
}
|
||||
Reference in New Issue
Block a user