Files
stocca-tre/server/StoccaTreRequest.ts
2022-07-08 09:31:34 +02:00

23 lines
549 B
TypeScript

export type HttpMethod = "POST" | "GET" | "PUT" | "DELETE";
export type RouteDefinition = {
pattern: RegExp;
method: HttpMethod;
};
export default class StoccaTreRequest {
constructor(
public method: HttpMethod,
public route: string,
public body: string | null,
) {}
match(route: RouteDefinition): RegExpExecArray | null {
const patternResult = route.pattern.exec(this.route);
if (route.method !== this.method) {
return null;
}
return patternResult;
}
}