rexuws
Version:
An express-like framework built on top of uWebsocket.js aims at simple codebase and high performance
33 lines (32 loc) • 1.25 kB
TypeScript
import { HttpMethod } from '../../utils/types';
import { IRouting, IRouteBaseHandler, Ctor } from './types';
/**
* @abstract
* Compatible layer to map user defined http endpoint to uWebSockets.js
*/
export default abstract class AbstractRoutingParser<T extends IRouteBaseHandler = IRouteBaseHandler, U extends Ctor = Ctor> implements IRouting<U> {
/**
* A single store consists of method,path, middlewares
*/
protected routeHandlers: Map<string, T>;
/**
* An abstract method to describe how arguments in http method gets stored into `routeHandlers`
*
* In the method's body, use `this.routeHandlers.set(key,routeHandler)` for future usage
*
* @param method
* @param args
*/
protected abstract add(method: HttpMethod, args: unknown[]): this;
get(...args: Parameters<U>): this;
post(...args: Parameters<U>): this;
put(...args: Parameters<U>): this;
patch(...args: Parameters<U>): this;
del(...args: Parameters<U>): this;
trace(...args: Parameters<U>): this;
head(...args: Parameters<U>): this;
options(...args: Parameters<U>): this;
connect(...args: Parameters<U>): this;
any(...args: Parameters<U>): this;
all(...args: Parameters<U>): this;
}