mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-06-28 22:30:01 +00:00
Add type definitions for "koa-log" package
This commit is contained in:
33
types/koa-log/index.d.ts
vendored
Normal file
33
types/koa-log/index.d.ts
vendored
Normal file
@@ -0,0 +1,33 @@
|
||||
// Type definitions for koa-log 2.1
|
||||
// Project: https://github.com/vicanso/koa-log#readme
|
||||
// Definitions by: Uladzimir Havenchyk <https://github.com/havenchyk>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.3
|
||||
|
||||
import * as Koa from 'koa';
|
||||
|
||||
declare function koaLog(type: string): Koa.Middleware;
|
||||
|
||||
declare namespace koaLog {
|
||||
namespace morgan {
|
||||
function cookie(ctx: Koa.BaseContext, key: string): string;
|
||||
|
||||
function date(ctx: Koa.BaseContext, format: string): string;
|
||||
|
||||
function format(name: string): string;
|
||||
|
||||
function length(ctx: Koa.BaseContext): number | undefined;
|
||||
|
||||
function method(ctx: Koa.BaseContext): string;
|
||||
|
||||
function referrer(ctx: Koa.BaseContext): string;
|
||||
|
||||
function status(ctx: Koa.BaseContext): number;
|
||||
|
||||
function token(name: string, fn: (ctx: Koa.BaseContext) => string): void;
|
||||
|
||||
function url(ctx: Koa.BaseContext): string;
|
||||
}
|
||||
}
|
||||
|
||||
export = koaLog;
|
||||
10
types/koa-log/koa-log-tests.ts
Normal file
10
types/koa-log/koa-log-tests.ts
Normal file
@@ -0,0 +1,10 @@
|
||||
import Koa = require('koa');
|
||||
import koaLogger = require('koa-log');
|
||||
|
||||
koaLogger.morgan.token('request-body', (ctx: Koa.BaseContext) => JSON.stringify(ctx.request.body));
|
||||
koaLogger.morgan.token('response-body', (ctx: Koa.BaseContext) => JSON.stringify(ctx.body));
|
||||
|
||||
const app = new Koa();
|
||||
app.use(
|
||||
koaLogger(':status :method :url took :response-time ms :request-body :response-body')
|
||||
);
|
||||
23
types/koa-log/tsconfig.json
Normal file
23
types/koa-log/tsconfig.json
Normal file
@@ -0,0 +1,23 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es6"
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": true,
|
||||
"strictFunctionTypes": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"koa-log-tests.ts"
|
||||
]
|
||||
}
|
||||
1
types/koa-log/tslint.json
Normal file
1
types/koa-log/tslint.json
Normal file
@@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
Reference in New Issue
Block a user