From 477643b46bc24e9b76420ac658e87e1ff2b1f197 Mon Sep 17 00:00:00 2001 From: AmirSaber Sharifi Date: Sat, 23 Apr 2016 03:43:36 -0400 Subject: [PATCH] add koa-mount (#9055) --- koa-mount/koa-mount-tests.ts | 26 ++++++++++++++++++++++++++ koa-mount/koa-mount.d.ts | 23 +++++++++++++++++++++++ 2 files changed, 49 insertions(+) create mode 100644 koa-mount/koa-mount-tests.ts create mode 100644 koa-mount/koa-mount.d.ts diff --git a/koa-mount/koa-mount-tests.ts b/koa-mount/koa-mount-tests.ts new file mode 100644 index 0000000000..560938b22f --- /dev/null +++ b/koa-mount/koa-mount-tests.ts @@ -0,0 +1,26 @@ +/// +/// + +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"); + diff --git a/koa-mount/koa-mount.d.ts b/koa-mount/koa-mount.d.ts new file mode 100644 index 0000000000..6c9c83bb73 --- /dev/null +++ b/koa-mount/koa-mount.d.ts @@ -0,0 +1,23 @@ +// Type definitions for koa-mount v2.0.0 +// Project: https://github.com/koajs/mount +// Definitions by: AmirSaber Sharifi +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +/// + +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; +}