Joachim Van Herwegen 6248ed0938 refactor: Replace linting configurations
The previous package was outdated, preventing us from updating TS.
This one also lints YAML and JSON,
and applies many more rules to the test files,
explaining all the changes in this PR.
2023-11-02 09:49:17 +01:00

16 lines
464 B
TypeScript

import type { IncomingMessage } from 'http';
import type { Guarded } from '../util/GuardedStream';
/**
* An incoming HTTP request;
*/
export type HttpRequest = Guarded<IncomingMessage>;
/**
* Checks if the given stream is an HttpRequest.
*/
export function isHttpRequest(stream: unknown): stream is HttpRequest {
const req = stream as HttpRequest;
return typeof req.socket === 'object' && typeof req.url === 'string' && typeof req.method === 'string';
}