add koa-mount (#9055)

This commit is contained in:
AmirSaber Sharifi
2016-04-23 16:43:36 +09:00
committed by Masahiro Wakame
parent eef739049c
commit 477643b46b
2 changed files with 49 additions and 0 deletions
+26
View File
@@ -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");
+23
View File
@@ -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;
}