isHttpRequest (types/index.ts)

requestrepo · frontend/src/types/index.ts · typescript · MIT
email

TypeScript interfaces and type guards for session and request data structures in a web app.

// Source: https://github.com/adrgs/requestrepo | License: MIT | Copyright 2023 Dragos Albastroiu
// Provided via justclaw.it.com; keep this notice with the code.
// Session types
export interface Session {
  subdomain: string;
  token: string;
  createdAt: string;
}

// Request types (discriminated union)
export interface BaseRequest {
  _id: string;
  type: "http" | "dns" | "smtp";
  date: number;
  ip: string;
  port?: number;
  country?: string;
  raw: string;
  uid: string;
}

export interface HttpRequest extends BaseRequest {
  type: "http";
  method: string;
  path: string;
  query: string | null;
  fragment: string | null;
  protocol: string;
  url: string;
  headers: Record<string, string>;
}

export interface DnsRequest extends BaseRequest {
  type: "dns";
  domain: string; // Th

... (truncated -- full source via MCP)

See the full source, get the GitHub permalink, and search for more like it.

Get a free API key