mirror of
https://github.com/wassname/DefinitelyTyped.git
synced 2026-09-07 16:30:12 +08:00
Added definition files for koa-json (#8873)
This commit is contained in:
committed by
Masahiro Wakame
parent
73fa26213a
commit
d3407b5a41
@@ -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)
|
||||
Vendored
+40
@@ -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;
|
||||
}
|
||||
Reference in New Issue
Block a user