Hacktoberfest 2026: los issues que los mantenedores marcaron para octubre, abiertos y aptos para principiantes. Explorar issues de Hacktoberfest

Add endpoint and URL helpers for mapped ports

Abierto
#1,546 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 1 día

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
3/5
Tiempo estimado
1-2 días
Aptitud para principiantes
76/100
Tipo de issue
Nueva funcionalidad
Claridad
Bien especificado
Estado de actividad
Activo
Stack tecnológico
docker, node.js, typescript
Área
api, testing

Línea de trabajo

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.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

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.
Lenguaje dominante
TypeScript
Estrellas
2.6k
Forks
274
Merge medio
1 d 14 h
PR fusionados (30 d)
44

Preparar el entorno

Abrir en Codespaces

Inicia el contenedor de desarrollo del proyecto en tu navegador, con tu propia cuenta de GitHub.

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de testcontainers/testcontainers-node

Todos los issues de testcontainers/testcontainers-node

Issues similares

Más issues de TypeScript

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.