test schmest
This commit is contained in:
parent
277f5a313e
commit
d43bf30a08
2
dist/index.d.ts
vendored
2
dist/index.d.ts
vendored
@ -7,7 +7,7 @@ export default class Flummpress {
|
|||||||
private middleware;
|
private middleware;
|
||||||
router: Router;
|
router: Router;
|
||||||
constructor();
|
constructor();
|
||||||
use<T>(nameOrRouter: string | Router, factory?: () => T): this;
|
use<T>(plugin: string | Router | Handler, factory?: () => T): this;
|
||||||
resolve<T>(name: string): T;
|
resolve<T>(name: string): T;
|
||||||
private processPipeline;
|
private processPipeline;
|
||||||
listen(...args: any[]): this;
|
listen(...args: any[]): this;
|
||||||
|
12
dist/index.js
vendored
12
dist/index.js
vendored
@ -20,11 +20,13 @@ export default class Flummpress {
|
|||||||
this.router = new Router();
|
this.router = new Router();
|
||||||
this.middleware = [];
|
this.middleware = [];
|
||||||
}
|
}
|
||||||
use(nameOrRouter, factory) {
|
use(plugin, factory) {
|
||||||
if (typeof nameOrRouter === "string" && factory)
|
if (typeof plugin === "string" && factory)
|
||||||
this.container.register(nameOrRouter, factory);
|
this.container.register(plugin, factory);
|
||||||
else if (nameOrRouter instanceof Router)
|
else if (plugin instanceof Router)
|
||||||
this.router.use(nameOrRouter);
|
this.router.use(plugin);
|
||||||
|
else if (typeof plugin === "function")
|
||||||
|
this.middleware.push(plugin);
|
||||||
else
|
else
|
||||||
throw new TypeError("Invalid arguments provided to use()");
|
throw new TypeError("Invalid arguments provided to use()");
|
||||||
return this;
|
return this;
|
||||||
|
14
src/index.ts
14
src/index.ts
@ -20,19 +20,13 @@ export default class Flummpress {
|
|||||||
this.middleware = [];
|
this.middleware = [];
|
||||||
}
|
}
|
||||||
|
|
||||||
/*public use(plugin: Router | Handler): this {
|
public use<T>(plugin: string | Router | Handler, factory?: () => T): this {
|
||||||
if(plugin instanceof Router)
|
if(typeof plugin === "string" && factory)
|
||||||
|
this.container.register(plugin, factory);
|
||||||
|
else if(plugin instanceof Router)
|
||||||
this.router.use(plugin);
|
this.router.use(plugin);
|
||||||
else if(typeof plugin === "function")
|
else if(typeof plugin === "function")
|
||||||
this.middleware.push(plugin);
|
this.middleware.push(plugin);
|
||||||
return this;
|
|
||||||
}*/
|
|
||||||
|
|
||||||
public use<T>(nameOrRouter: string | Router, factory?: () => T): this {
|
|
||||||
if(typeof nameOrRouter === "string" && factory)
|
|
||||||
this.container.register(nameOrRouter, factory);
|
|
||||||
else if(nameOrRouter instanceof Router)
|
|
||||||
this.router.use(nameOrRouter);
|
|
||||||
else
|
else
|
||||||
throw new TypeError("Invalid arguments provided to use()");
|
throw new TypeError("Invalid arguments provided to use()");
|
||||||
return this;
|
return this;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user