* Introduced a new HTML frontend for network speed testing with a responsive UI * Implemented backend server functionality to serve the frontend and handle speed test APIs * Added speed test logic for downloading and uploading data, including progress tracking and result validation * Created README-SPEEDTEST.md for documentation on application architecture, setup, and usage. * Updated package.json to include necessary scripts and dependencies for development and testing
53 lines
1.2 KiB
TypeScript
53 lines
1.2 KiB
TypeScript
import {assertUnreachable} from '@techniker-me/tools';
|
|
|
|
export enum HttpMethod {
|
|
GET = 0,
|
|
POST = 1,
|
|
PUT = 2,
|
|
DELETE = 3,
|
|
PATCH = 4,
|
|
OPTIONS = 5
|
|
}
|
|
|
|
export type HttpMethodType = keyof typeof HttpMethod;
|
|
|
|
export class HttpMethodMapping {
|
|
public static convertHttpMethodTypeToHttpMethod(method: HttpMethodType): HttpMethod {
|
|
switch (method) {
|
|
case 'GET':
|
|
return HttpMethod.GET;
|
|
case 'POST':
|
|
return HttpMethod.POST;
|
|
case 'PUT':
|
|
return HttpMethod.PUT;
|
|
case 'DELETE':
|
|
return HttpMethod.DELETE;
|
|
case 'PATCH':
|
|
return HttpMethod.PATCH;
|
|
case 'OPTIONS':
|
|
return HttpMethod.OPTIONS;
|
|
default:
|
|
assertUnreachable(method);
|
|
}
|
|
}
|
|
|
|
public static convertHttpMethodToHttpMethodType(method: HttpMethod): HttpMethodType {
|
|
switch (method) {
|
|
case HttpMethod.GET:
|
|
return 'GET';
|
|
case HttpMethod.POST:
|
|
return 'POST';
|
|
case HttpMethod.PUT:
|
|
return 'PUT';
|
|
case HttpMethod.DELETE:
|
|
return 'DELETE';
|
|
case HttpMethod.PATCH:
|
|
return 'PATCH';
|
|
case HttpMethod.OPTIONS:
|
|
return 'OPTIONS';
|
|
default:
|
|
assertUnreachable(method);
|
|
}
|
|
}
|
|
}
|