Added definition files for koa-json (#8873)

This commit is contained in:
Alex Friedman
2016-04-12 21:52:08 +09:00
committed by Masahiro Wakame
parent 73fa26213a
commit d3407b5a41
2 changed files with 55 additions and 0 deletions
+15
View File
@@ -0,0 +1,15 @@
/// <reference path="../koa/koa.d.ts" />
/// <reference path="koa-json.d.ts" />
import * as Koa from "koa";
import * as json from 'koa-json';
const app = new Koa();
app.use(json({
pretty: false,
param: 'pretty',
spaces: 2
}));
app.listen(80)
+40
View File
@@ -0,0 +1,40 @@
// Type definitions for koa-json v2.x
// Project: https://github.com/koajs/json
// Definitions by: Alex Friedman <https://github.com/brooklyndev/>
// Definitions: https://github.com/brooklyndev/DefinitelyTyped
/* =================== USAGE ===================
import * as Koa from 'koa';
import * as json from 'koa-json';
const app = new Koa();
app.use(json());
=============================================== */
/// <reference path="../koa/koa.d.ts" />
declare module "koa-json" {
import * as Koa from "koa";
function json(opts?:{
/**
* default to pretty response [true]
*/
pretty?: boolean,
/**
* optional query-string param for pretty responses [none]
*/
param?: string,
/**
* JSON spaces [2]
*/
spaces?: number
}) : { (ctx: Koa.Context, next?: () => any): any } ;
namespace json {}
export = json;
}