test schmest

This commit is contained in:
Flummi 2025-03-24 14:38:12 +01:00
parent 277f5a313e
commit d43bf30a08
3 changed files with 12 additions and 16 deletions

2
dist/index.d.ts vendored
View File

@ -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
View File

@ -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;

View File

@ -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;