mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-12-03 19:51:53 +00:00
add koa-mount (#9055)
This commit is contained in:
committed by
Masahiro Wakame
parent
eef739049c
commit
477643b46b
@@ -0,0 +1,26 @@
|
||||
/// <reference path="../koa/koa.d.ts" />
|
||||
/// <reference path="koa-mount.d.ts" />
|
||||
|
||||
import * as Koa from "koa";
|
||||
import mount = require("koa-mount");
|
||||
|
||||
const a = new Koa();
|
||||
|
||||
a.use((next) => {
|
||||
this.body = "Hello";
|
||||
})
|
||||
|
||||
const b = new Koa();
|
||||
|
||||
b.use((next) => {
|
||||
this.body = "World";
|
||||
});
|
||||
|
||||
const app = new Koa();
|
||||
|
||||
app.use(mount("/hello", a));
|
||||
app.use(mount("/world", b));
|
||||
|
||||
app.listen(3000);
|
||||
console.log("listening on port 3000");
|
||||
|
||||
Vendored
+23
@@ -0,0 +1,23 @@
|
||||
// Type definitions for koa-mount v2.0.0
|
||||
// Project: https://github.com/koajs/mount
|
||||
// Definitions by: AmirSaber Sharifi <https://github.com/amirsaber>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
/// <reference path="../koa/koa.d.ts" />
|
||||
|
||||
declare module "koa-mount" {
|
||||
|
||||
import * as Koa from "koa";
|
||||
|
||||
interface Function { (ctx: Koa.Context, next?: () => any): any }
|
||||
|
||||
function mount(app: Function): Function;
|
||||
|
||||
function mount(app: Koa): Function;
|
||||
|
||||
function mount(prefix: string, app: Function): Function;
|
||||
|
||||
function mount(prefix: string, app: Koa): Function;
|
||||
|
||||
export = mount;
|
||||
}
|
||||
Reference in New Issue
Block a user