Skip to content

Instantly share code, notes, and snippets.

@Kamilius
Created July 10, 2025 07:18
Show Gist options
  • Select an option

  • Save Kamilius/837abfb3dc647d367e8ae5b75d665dd6 to your computer and use it in GitHub Desktop.

Select an option

Save Kamilius/837abfb3dc647d367e8ae5b75d665dd6 to your computer and use it in GitHub Desktop.
Prompt Markdown structure example

TypeScript and HTML Hardcoded API Endpoint Analyzer

Analyze TypeScript and HTML files to identify hardcoded API endpoints that may require refactoring.

Input Requirements

  • A TypeScript source file
  • Its corresponding HTML template file

Analysis Scope

Extract and analyze all string literals and template literals that appear to be API URLs or endpoints.

Exclusion Criteria

Do not include strings that are:

  1. Used for analytics or logging
  2. Related to navigation or routing
  3. Technical identifiers:
    • Comments
    • CSS classes
    • Image sources
    • Date/time formats
    • Empty strings
    • Icon names
    • Device modes
    • Storage keys
    • Existing environment variable references
    • State keys
    • Form control names
    • Strings inside "innerHTML" bindings

Output Format

Summary Section

### Analysis Summary

- Total endpoints discovered: <count>
- Hardcoded endpoints: <count>
- Endpoints needing review: <count>

Endpoint Entries

Group by file path, each entry containing:

  1. Endpoint string with line number
  2. Full context (variable/function/element name)
  3. Usage assessment and confidence level
  4. Clickable source reference

Example format:

src/app/example.service.ts

  1. "https://api.example.com/v1/users"

    • Location: src/app/example.service.ts:27
    • Context: UserService.getUsers
    • Assessment: Hardcoded API endpoint (High confidence)
  2. "/api/v2/orders"

    • Location: src/app/example.component.ts:58
    • Context: OrderComponent.fetchOrders
    • Assessment: Relative API endpoint (Medium confidence)

Review Process

  1. List ambiguous endpoints separately
  2. Flag endpoints inside configuration objects for review
  3. Request user confirmation for uncertain cases
  4. Maintain original string context
  5. Provide clickable file references

Do not modify source files unless explicitly requested.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment