chore: default to port 8000
All checks were successful
Rust / check (push) Successful in 35s
Rust / test (push) Successful in 29s
Docker / build (push) Successful in 1m19s

This commit is contained in:
2026-06-16 14:39:53 +02:00
parent bfc7bd4f7c
commit 8268bd9692
6 changed files with 18 additions and 18 deletions

View File

@@ -74,11 +74,11 @@ COPY --from=builder /usr/local/bin/pokedex-api /usr/local/bin/pokedex-api
ARG GIT_SHA=unknown ARG GIT_SHA=unknown
ENV GIT_SHA=$GIT_SHA \ ENV GIT_SHA=$GIT_SHA \
BIND_ADDR=0.0.0.0:5000 BIND_ADDR=0.0.0.0:8000
EXPOSE 5000 EXPOSE 8000
USER app USER app
HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \ HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \
CMD curl -fsS http://127.0.0.1:5000/health || exit 1 CMD curl -fsS http://127.0.0.1:8000/health || exit 1
CMD ["pokedex-api"] CMD ["pokedex-api"]

View File

@@ -4,7 +4,7 @@ CARGO ?= cargo
DOCKER ?= docker DOCKER ?= docker
IMAGE ?= pokedex-api IMAGE ?= pokedex-api
TAG ?= local TAG ?= local
BASE_URL ?= http://localhost:5000 BASE_URL ?= http://localhost:8000
POKEMON ?= mewtwo POKEMON ?= mewtwo
PLATFORMS ?= linux/amd64,linux/arm64 PLATFORMS ?= linux/amd64,linux/arm64
GIT_SHA ?= $(shell git rev-parse HEAD 2>/dev/null || printf unknown) GIT_SHA ?= $(shell git rev-parse HEAD 2>/dev/null || printf unknown)
@@ -15,7 +15,7 @@ help:
@printf 'Available targets:\n' @printf 'Available targets:\n'
@printf ' make run Run the API locally with cargo\n' @printf ' make run Run the API locally with cargo\n'
@printf ' make docker-build Build the Docker image\n' @printf ' make docker-build Build the Docker image\n'
@printf ' make docker-run Run the Docker image on port 5000\n' @printf ' make docker-run Run the Docker image on port 8000\n'
@printf ' make cli-health Call /health through the CLI helper\n' @printf ' make cli-health Call /health through the CLI helper\n'
@printf ' make cli-pokemon Call /pokemon/$${POKEMON} through the CLI helper\n' @printf ' make cli-pokemon Call /pokemon/$${POKEMON} through the CLI helper\n'
@printf ' make cli-translated Call /pokemon/translated/$${POKEMON} through the CLI helper\n' @printf ' make cli-translated Call /pokemon/translated/$${POKEMON} through the CLI helper\n'
@@ -34,7 +34,7 @@ docker-build:
$(DOCKER) build -t $(IMAGE) . $(DOCKER) build -t $(IMAGE) .
docker-run: docker-run:
$(DOCKER) run --rm -p 5000:5000 $(IMAGE) $(DOCKER) run --rm -p 8000:8000 $(IMAGE)
cli-health: cli-health:
$(CARGO) run --bin pokedex-cli -- health $(CARGO) run --bin pokedex-cli -- health

View File

@@ -37,7 +37,7 @@ Then run the service:
make run make run
``` ```
The API listens on `0.0.0.0:5000` by default. The API listens on `0.0.0.0:8000` by default.
## CLI helper ## CLI helper
@@ -47,7 +47,7 @@ With the API running in another terminal, call it through the small helper binar
make cli-health make cli-health
make cli-pokemon make cli-pokemon
make cli-translated make cli-translated
make cli-pokemon POKEMON=pikachu BASE_URL=http://localhost:5000 make cli-pokemon POKEMON=pikachu BASE_URL=http://localhost:8000
``` ```
## Endpoints ## Endpoints
@@ -110,7 +110,7 @@ External contract tests are separated from the normal deterministic test suite.
| Variable | Default | Description | | Variable | Default | Description |
| --------------------------- | ------------------------------------------- | -------------------------- | | --------------------------- | ------------------------------------------- | -------------------------- |
| `BIND_ADDR` | `0.0.0.0:5000` | HTTP bind address | | `BIND_ADDR` | `0.0.0.0:8000` | HTTP bind address |
| `POKEAPI_BASE_URL` | `https://pokeapi.co/api/v2` | PokéAPI base URL | | `POKEAPI_BASE_URL` | `https://pokeapi.co/api/v2` | PokéAPI base URL |
| `FUN_TRANSLATIONS_BASE_URL` | `https://api.funtranslations.mercxry.me/v1` | FunTranslations base URL | | `FUN_TRANSLATIONS_BASE_URL` | `https://api.funtranslations.mercxry.me/v1` | FunTranslations base URL |
| `REQUEST_TIMEOUT_SECONDS` | `5` | Upstream HTTP timeout | | `REQUEST_TIMEOUT_SECONDS` | `5` | Upstream HTTP timeout |

View File

@@ -4,7 +4,7 @@ info:
version: 0.1.0 version: 0.1.0
description: REST API for the TrueLayer Pokémon challenge. description: REST API for the TrueLayer Pokémon challenge.
servers: servers:
- url: http://localhost:5000 - url: http://localhost:8000
paths: paths:
/health: /health:
get: get:

View File

@@ -4,7 +4,7 @@
use std::{env, process::ExitCode, time::Duration}; use std::{env, process::ExitCode, time::Duration};
const DEFAULT_BASE_URL: &str = "http://localhost:5000"; const DEFAULT_BASE_URL: &str = "http://localhost:8000";
const REQUEST_TIMEOUT: Duration = Duration::from_secs(10); const REQUEST_TIMEOUT: Duration = Duration::from_secs(10);
#[tokio::main] #[tokio::main]
@@ -166,7 +166,7 @@ fn trim_base_url(base_url: &str) -> String {
} }
const fn usage() -> &'static str { const fn usage() -> &'static str {
"Usage:\n pokedex-cli [--base-url URL] health\n pokedex-cli [--base-url URL] metrics\n pokedex-cli [--base-url URL] pokemon <name>\n pokedex-cli [--base-url URL] translated <name>\n\nExamples:\n pokedex-cli pokemon mewtwo\n pokedex-cli translated mewtwo\n pokedex-cli --base-url http://localhost:5000 pokemon pikachu" "Usage:\n pokedex-cli [--base-url URL] health\n pokedex-cli [--base-url URL] metrics\n pokedex-cli [--base-url URL] pokemon <name>\n pokedex-cli [--base-url URL] translated <name>\n\nExamples:\n pokedex-cli pokemon mewtwo\n pokedex-cli translated mewtwo\n pokedex-cli --base-url http://localhost:8000 pokemon pikachu"
} }
#[derive(Debug, thiserror::Error)] #[derive(Debug, thiserror::Error)]
@@ -204,23 +204,23 @@ mod tests {
} }
} }
); );
assert_eq!(args.url(), "http://localhost:5000/pokemon/mewtwo"); assert_eq!(args.url(), "http://localhost:8000/pokemon/mewtwo");
} }
#[test] #[test]
fn parses_custom_base_url_and_translated_command() { fn parses_custom_base_url_and_translated_command() {
let args = parse_args([ let args = parse_args([
"--base-url", "--base-url",
"http://localhost:5000/", "http://localhost:8000/",
"translated", "translated",
"mr-mime", "mr-mime",
]) ])
.expect("args should parse"); .expect("args should parse");
assert_eq!(args.base_url, "http://localhost:5000"); assert_eq!(args.base_url, "http://localhost:8000");
assert_eq!( assert_eq!(
args.url(), args.url(),
"http://localhost:5000/pokemon/translated/mr-mime" "http://localhost:8000/pokemon/translated/mr-mime"
); );
} }

View File

@@ -66,7 +66,7 @@ fn env_or_string(name: &'static str, default: &str) -> String {
} }
fn default_bind_addr() -> SocketAddr { fn default_bind_addr() -> SocketAddr {
SocketAddr::from(([0, 0, 0, 0], 5000)) SocketAddr::from(([0, 0, 0, 0], 8000))
} }
const fn validate_rate_limit(per_second: f64, burst: u32) -> Result<(), ConfigError> { const fn validate_rate_limit(per_second: f64, burst: u32) -> Result<(), ConfigError> {
@@ -101,7 +101,7 @@ mod tests {
fn default_config_is_valid_for_local_development() { fn default_config_is_valid_for_local_development() {
let config = AppConfig::default_local(); let config = AppConfig::default_local();
assert_eq!(config.bind_addr.port(), 5000); assert_eq!(config.bind_addr.port(), 8000);
assert_eq!(config.pokeapi_base_url, "https://pokeapi.co/api/v2"); assert_eq!(config.pokeapi_base_url, "https://pokeapi.co/api/v2");
assert!((config.rate_limit_per_second - 20.0).abs() < f64::EPSILON); assert!((config.rate_limit_per_second - 20.0).abs() < f64::EPSILON);
} }