Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

Add endpoint and URL helpers for mapped ports

Aperta
#1,546 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
3/5
Tempo stimato
1-2 giorni
Idoneità per principianti
76/100
Tipo di issue
Funzionalità
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
docker, node.js, typescript
Ambito
api, testing

Direzione di ricerca

Start with the StartedTestContainer interface in packages/testcontainers/src/test-container.ts, then read StartedGenericContainer and AbstractStartedContainer in the two generic-container files listed in the issue. Trace how mapped ports and hosts are exposed, including IPv6 URL formatting. Done means both helpers return the specified endpoint and URL and the interface, implementation, and forwarder are updated.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

enhancement minor

What happens

The most common line written against a started container is a hand-assembled address:

const url = `http://${container.getHost()}:${container.getMappedPort(8080)}`;

It appears throughout the docs and module sources, and every module re-implements it for its own URL getters. It is easy to get subtly wrong (forgetting the mapped port, hardcoding localhost).

Expected

Helpers on StartedTestContainer:

  • getEndpoint(port) returns host:port
  • getUrl(port, scheme = "http") returns scheme://host:port
const url = container.getUrl(8080);

Modules can build their own getters on these.

Where

  • packages/testcontainers/src/test-container.ts
  • packages/testcontainers/src/generic-container/started-generic-container.ts
  • packages/testcontainers/src/generic-container/abstract-started-container.ts

Notes

  • Go has Endpoint(ctx, proto) for the first exposed port and PortEndpoint(ctx, port, proto).
  • IPv6 hosts need brackets in a URL, which is one more reason to build it in one place.
  • Related: #1538 (connection getter names across modules).

Dependencies

  • Nothing blocks this. It can start now.
  • Changes StartedTestContainer, which today means the interface, StartedGenericContainer and the forwarder on AbstractStartedContainer. Several other issues do the same. The edits do not overlap, so they can go in parallel.
Lingua principale
TypeScript
Stelle
2.6k
Fork
274
Merge medio
1g 14h
PR unite (30g)
44

Preparare l'ambiente

Apri in Codespaces

Avvia il container di sviluppo del progetto nel browser, con il tuo account GitHub.

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di testcontainers/testcontainers-node

Tutte le issue di testcontainers/testcontainers-node

Issue simili

Altre issue su TypeScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.