From d6e65ef6317aa3f7ad29f71d83578c42e442a2e2 Mon Sep 17 00:00:00 2001 From: "Anaz S. Aji" Date: Wed, 1 Jul 2026 10:30:07 +0700 Subject: [PATCH] fix: standardize remaining port references to 9090 Complete port standardization started in #274 which only updated the Dockerfile and README. This fixes the remaining 3000 references so the default port is consistently 9090 across code, config, and docs. Changes: - config/deploy: .env.example, docker-compose.yml, docker-compose.prod.yml - code defaults: DSN host fallback in trapfall-core (generate_dsn), trapfall-db (create_project default, rotate_dsn, extract_dsn_host), trapfalld (auth.rs, server.rs Host-header fallback) - openapi.yaml server url - docs/guide/*.md (docker, getting-started, vps-deployment, alerts, configuration, migration, sdk-integration) Left intentionally as illustrative/test fixtures: - config.rs normalize_dsn_host doc example + test (errors.app.io:3000) proves the parser handles arbitrary non-default ports - proto mask_dsn_key test fixture (localhost:3000/42) - web/ws.ts reconnect delay (3000 ms, not a port) --- .env.example | 10 +++++----- crates/trapfall-core/src/lib.rs | 2 +- crates/trapfall-db/src/common.rs | 4 ++-- crates/trapfall-db/src/postgres.rs | 2 +- crates/trapfall-db/src/sqlite.rs | 6 +++--- crates/trapfalld/src/auth.rs | 2 +- crates/trapfalld/src/openapi.yaml | 2 +- crates/trapfalld/src/server.rs | 4 ++-- docker-compose.prod.yml | 6 +++--- docker-compose.yml | 4 ++-- docs/guide/alerts.md | 8 ++++---- docs/guide/configuration.md | 4 ++-- docs/guide/docker.md | 8 ++++---- docs/guide/getting-started.md | 20 ++++++++++---------- docs/guide/migration.md | 2 +- docs/guide/sdk-integration.md | 10 +++++----- docs/guide/vps-deployment.md | 10 +++++----- 17 files changed, 52 insertions(+), 52 deletions(-) diff --git a/.env.example b/.env.example index 6784261..dd95d28 100644 --- a/.env.example +++ b/.env.example @@ -2,8 +2,8 @@ # Copy to .env and customize for your environment. # ── Server ───────────────────────────────────────────────────────────── -# HTTP listen address (default: 0.0.0.0:3000) -TRAPFALL_LISTEN=0.0.0.0:3000 +# HTTP listen address (default: 0.0.0.0:9090) +TRAPFALL_LISTEN=0.0.0.0:9090 # Log level: trace, debug, info, warn, error (default: info) RUST_LOG=trapfall=info @@ -45,8 +45,8 @@ TRAPFALL_CORS_ORIGINS= # ── Sentry SDK Compatibility ────────────────────────────────────────── # When using Sentry SDKs, point them to your TrapFall instance: # -# Python: sentry_sdk.init(dsn="http://@localhost:3000/0") -# Node.js: Sentry.init({ dsn: "http://@localhost:3000/0" }) -# Rust: sentry::init(("http://@localhost:3000/0", sentry::ClientOptions::default())) +# Python: sentry_sdk.init(dsn="http://@localhost:9090/0") +# Node.js: Sentry.init({ dsn: "http://@localhost:9090/0" }) +# Rust: sentry::init(("http://@localhost:9090/0", sentry::ClientOptions::default())) # # The DSN key is generated per-project via the dashboard. diff --git a/crates/trapfall-core/src/lib.rs b/crates/trapfall-core/src/lib.rs index fdc00a9..b4d2f0f 100644 --- a/crates/trapfall-core/src/lib.rs +++ b/crates/trapfall-core/src/lib.rs @@ -31,5 +31,5 @@ pub fn generate_dsn_with(host: &str, project_id: &str) -> String { /// When creating projects via CLI (no request context), we use a generic DSN. /// Note: project_id is set to "1" as placeholder — should be regenerated with real project ID. pub fn generate_dsn() -> String { - generate_dsn_with("localhost:3000", "1") + generate_dsn_with("localhost:9090", "1") } diff --git a/crates/trapfall-db/src/common.rs b/crates/trapfall-db/src/common.rs index e88b913..225f69a 100644 --- a/crates/trapfall-db/src/common.rs +++ b/crates/trapfall-db/src/common.rs @@ -217,8 +217,8 @@ pub fn extract_dsn_key(dsn: &str) -> String { pub fn extract_dsn_host(dsn: &str) -> String { dsn.split('@') .nth(1) - .map(|s| s.split('/').next().unwrap_or("localhost:3000")) - .unwrap_or("localhost:3000") + .map(|s| s.split('/').next().unwrap_or("localhost:9090")) + .unwrap_or("localhost:9090") .to_string() } diff --git a/crates/trapfall-db/src/postgres.rs b/crates/trapfall-db/src/postgres.rs index c5b10d5..38b8707 100644 --- a/crates/trapfall-db/src/postgres.rs +++ b/crates/trapfall-db/src/postgres.rs @@ -48,7 +48,7 @@ impl Database for PostgresBackend { // ── Projects ─────────────────────────────────────────────────────── async fn create_project(&self, slug: &str, name: &str) -> Result { - self.create_project_with_host(slug, name, "localhost:3000").await + self.create_project_with_host(slug, name, "localhost:9090").await } async fn create_project_with_host(&self, slug: &str, name: &str, host: &str) -> Result { diff --git a/crates/trapfall-db/src/sqlite.rs b/crates/trapfall-db/src/sqlite.rs index 8dabb33..89debd1 100644 --- a/crates/trapfall-db/src/sqlite.rs +++ b/crates/trapfall-db/src/sqlite.rs @@ -45,7 +45,7 @@ impl Database for SqliteBackend { // ── Projects ─────────────────────────────────────────────────────── async fn create_project(&self, slug: &str, name: &str) -> Result { - self.create_project_with_host(slug, name, "localhost:3000").await + self.create_project_with_host(slug, name, "localhost:9090").await } async fn create_project_with_host(&self, slug: &str, name: &str, host: &str) -> Result { @@ -114,8 +114,8 @@ impl Database for SqliteBackend { .dsn .split('@') .nth(1) - .map(|s| s.split('/').next().unwrap_or("localhost:3000")) - .unwrap_or("localhost:3000"); + .map(|s| s.split('/').next().unwrap_or("localhost:9090")) + .unwrap_or("localhost:9090"); let new_dsn = generate_dsn_with(host, project_id); let new_dsn_key = extract_dsn_key(&new_dsn); sqlx::query("UPDATE projects SET dsn = ?, dsn_key = ? WHERE id = ?") diff --git a/crates/trapfalld/src/auth.rs b/crates/trapfalld/src/auth.rs index 13d9e74..d2ce698 100644 --- a/crates/trapfalld/src/auth.rs +++ b/crates/trapfalld/src/auth.rs @@ -116,7 +116,7 @@ pub async fn setup( let host = state .config .dsn_host() - .unwrap_or_else(|| headers.get("host").and_then(|v| v.to_str().ok()).unwrap_or("localhost:3000").to_string()); + .unwrap_or_else(|| headers.get("host").and_then(|v| v.to_str().ok()).unwrap_or("localhost:9090").to_string()); let project = store .create_project_with_host("default", "Default Project", &host) .await diff --git a/crates/trapfalld/src/openapi.yaml b/crates/trapfalld/src/openapi.yaml index 2e07392..11d788c 100644 --- a/crates/trapfalld/src/openapi.yaml +++ b/crates/trapfalld/src/openapi.yaml @@ -16,7 +16,7 @@ info: name: Apache-2.0 servers: - - url: http://localhost:3000 + - url: http://localhost:9090 description: Local development tags: diff --git a/crates/trapfalld/src/server.rs b/crates/trapfalld/src/server.rs index 0a09a3d..569c856 100644 --- a/crates/trapfalld/src/server.rs +++ b/crates/trapfalld/src/server.rs @@ -205,11 +205,11 @@ async fn create_project( let slug = req.slug.unwrap_or_else(|| req.name.to_lowercase().replace(' ', "-")); // Prefer configured `public_url` (TRAPFALL_PUBLIC_URL) for DSN generation. // Fall back to the request Host header so local dev keeps working without - // extra config (e.g. user accesses via http://localhost:3000). + // extra config (e.g. user accesses via http://localhost:9090). let host = state .config .dsn_host() - .unwrap_or_else(|| headers.get("host").and_then(|v| v.to_str().ok()).unwrap_or("localhost:3000").to_string()); + .unwrap_or_else(|| headers.get("host").and_then(|v| v.to_str().ok()).unwrap_or("localhost:9090").to_string()); let project = store.create_project_with_host(&slug, &req.name, &host).await.map_err(|e| { tracing::warn!("Create project failed: {e}"); StatusCode::CONFLICT diff --git a/docker-compose.prod.yml b/docker-compose.prod.yml index 57b2236..46a3912 100644 --- a/docker-compose.prod.yml +++ b/docker-compose.prod.yml @@ -5,7 +5,7 @@ # Quick start: # 1. Copy .env.production to .env, edit values # 2. docker compose up -d -# 3. Open http://YOUR_VPS_IP:3000 → setup wizard +# 3. Open http://YOUR_VPS_IP:9090 → setup wizard # # SQLite mode (default, single file, zero extra deps): # docker compose up -d @@ -21,7 +21,7 @@ services: container_name: trapfall restart: unless-stopped ports: - - "${TRAPFALL_PORT:-3000}:3000" + - "${TRAPFALL_PORT:-9090}:9090" volumes: - trapfall-data:/data environment: @@ -31,7 +31,7 @@ services: - TRAPFALL_CORS_ORIGINS=${TRAPFALL_CORS_ORIGINS:-} command: > serve - --listen 0.0.0.0:3000 + --listen 0.0.0.0:9090 healthcheck: test: ["CMD", "/trapfall", "healthcheck"] interval: 30s diff --git a/docker-compose.yml b/docker-compose.yml index 96c23ec..c75d6ba 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -7,7 +7,7 @@ services: container_name: trapfall restart: unless-stopped ports: - - "${TRAPFALL_PORT:-3000}:3000" + - "${TRAPFALL_PORT:-9090}:9090" volumes: - trapfall-data:/data environment: @@ -17,7 +17,7 @@ services: - TRAPFALL_DATABASE_URL=${TRAPFALL_DATABASE_URL:-sqlite:/data/trapfall.db} command: > serve - --listen 0.0.0.0:3000 + --listen 0.0.0.0:9090 healthcheck: test: ["CMD", "/trapfall", "healthcheck"] interval: 30s diff --git a/docs/guide/alerts.md b/docs/guide/alerts.md index cac4d6c..c3d9cba 100644 --- a/docs/guide/alerts.md +++ b/docs/guide/alerts.md @@ -50,16 +50,16 @@ Conditions are JSON objects. Currently supports: ```bash # List rules -curl -b cookie http://localhost:3000/api/0/projects/my-app/rules +curl -b cookie http://localhost:9090/api/0/projects/my-app/rules # Create rule -curl -b cookie -X POST http://localhost:3000/api/0/projects/my-app/rules \ +curl -b cookie -X POST http://localhost:9090/api/0/projects/my-app/rules \ -H "Content-Type: application/json" \ -d '{"name":"Fatal Alert","conditions":{"level":"fatal"},"action_type":"webhook","action_config":{"url":"https://hooks.slack.com/..."}}' # Toggle rule -curl -b cookie -X POST http://localhost:3000/api/0/rules//toggle +curl -b cookie -X POST http://localhost:9090/api/0/rules//toggle # Delete rule -curl -b cookie -X DELETE http://localhost:3000/api/0/rules/ +curl -b cookie -X DELETE http://localhost:9090/api/0/rules/ ``` diff --git a/docs/guide/configuration.md b/docs/guide/configuration.md index 3e2480b..32f89db 100644 --- a/docs/guide/configuration.md +++ b/docs/guide/configuration.md @@ -61,14 +61,14 @@ services: trapfall: image: ghcr.io/codecoradev/trapfall:0.0.5 ports: - - "3000:3000" + - "9090:9090" volumes: - trapfall-data:/data environment: - RUST_LOG=trapfall=debug - TRAPFALL_SECURE_COOKIE=false - TRAPFALL_DATABASE_URL=sqlite:/data/trapfall.db - command: serve --listen 0.0.0.0:3000 + command: serve --listen 0.0.0.0:9090 ``` ## Database diff --git a/docs/guide/docker.md b/docs/guide/docker.md index 8290fa7..ca0819b 100644 --- a/docs/guide/docker.md +++ b/docs/guide/docker.md @@ -4,7 +4,7 @@ ```bash docker pull ghcr.io/codecoradev/trapfall:latest -docker run -d -p 3000:3000 -v trapfall-data:/data ghcr.io/codecoradev/trapfall:latest +docker run -d -p 9090:9090 -v trapfall-data:/data ghcr.io/codecoradev/trapfall:latest ``` ## Image Details @@ -36,7 +36,7 @@ services: container_name: trapfall restart: unless-stopped ports: - - "3000:3000" + - "9090:9090" volumes: - trapfall-data:/data environment: @@ -45,7 +45,7 @@ services: - TRAPFALL_DATABASE_URL=sqlite:/data/trapfall.db command: > serve - --listen 0.0.0.0:3000 + --listen 0.0.0.0:9090 healthcheck: test: ["CMD", "/trapfall", "healthcheck"] interval: 30s @@ -86,7 +86,7 @@ server { ssl_certificate_key /path/to/key.pem; location / { - proxy_pass http://127.0.0.1:3000; + proxy_pass http://127.0.0.1:9090; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; diff --git a/docs/guide/getting-started.md b/docs/guide/getting-started.md index aec1b69..08d3c28 100644 --- a/docs/guide/getting-started.md +++ b/docs/guide/getting-started.md @@ -14,12 +14,12 @@ docker pull ghcr.io/codecoradev/trapfall:latest # Run (SQLite, zero-config) docker run -d \ --name trapfall \ - -p 3000:3000 \ + -p 9090:9090 \ -v trapfall-data:/data \ ghcr.io/codecoradev/trapfall:latest ``` -Open `http://localhost:3000` → setup wizard. +Open `http://localhost:9090` → setup wizard. ### Docker Compose @@ -54,10 +54,10 @@ chmod +x trapfall ```bash # Start server -./trapfall serve --listen 0.0.0.0:3000 +./trapfall serve --listen 0.0.0.0:9090 # Or with custom database path -./trapfall --db /var/lib/trapfall.db serve --listen 0.0.0.0:3000 +./trapfall --db /var/lib/trapfall.db serve --listen 0.0.0.0:9090 ``` ## From Source @@ -70,14 +70,14 @@ cd trapfall cd web && npm ci && npm run build && cd .. # Build + run -cargo run --release -p trapfalld -- serve --listen 0.0.0.0:3000 +cargo run --release -p trapfalld -- serve --listen 0.0.0.0:9090 ``` ## Quick Start 1. **Start the server** (any method above) -2. **Open `http://localhost:3000`** → setup wizard appears on first run +2. **Open `http://localhost:9090`** → setup wizard appears on first run 3. **Create admin account** (email, name, password) @@ -89,24 +89,24 @@ cargo run --release -p trapfalld -- serve --listen 0.0.0.0:3000 ```js // JavaScript / Node.js - Sentry.init({ dsn: "https://@localhost:3000/" }); + Sentry.init({ dsn: "https://@localhost:9090/" }); ``` ```python # Python import sentry_sdk - sentry_sdk.init(dsn: "https://@localhost:3000/") + sentry_sdk.init(dsn: "https://@localhost:9090/") ``` ```rust // Rust - sentry::init(("https://@localhost:3000/", sentry::ClientOptions::default())); + sentry::init(("https://@localhost:9090/", sentry::ClientOptions::default())); ``` ```dart // Flutter / Dart await SentryFlutter.init((options) => { - options.dsn = "https://@localhost:3000/", + options.dsn = "https://@localhost:9090/", }); ``` diff --git a/docs/guide/migration.md b/docs/guide/migration.md index 637ccc4..aa9c1d9 100644 --- a/docs/guide/migration.md +++ b/docs/guide/migration.md @@ -62,7 +62,7 @@ Update your deployment to use the Postgres URL: ```bash TRAPFALL_DATABASE_URL=postgres://user:password@localhost:5432/trapfall \ - trapfall serve --listen 0.0.0.0:3000 + trapfall serve --listen 0.0.0.0:9090 ``` ## Notes diff --git a/docs/guide/sdk-integration.md b/docs/guide/sdk-integration.md index 795d9ed..225f2f8 100644 --- a/docs/guide/sdk-integration.md +++ b/docs/guide/sdk-integration.md @@ -18,7 +18,7 @@ TrapFall is compatible with the Sentry envelope protocol. Any Sentry SDK can sen fn main() { let _guard = sentry::init(( - "https://@your-server:3000/", + "https://@your-server:9090/", sentry::ClientOptions { release: Some(env!("CARGO_PKG_VERSION").into()), ..Default::default() @@ -38,7 +38,7 @@ fn main() { import sentry_sdk sentry_sdk.init( - dsn="https://@your-server:3000/", + dsn="https://@your-server:9090/", traces_sample_rate=0.0, # TrapFall is error-only, no tracing ) @@ -57,7 +57,7 @@ except Exception: const Sentry = require("@sentry/node"); Sentry.init({ - dsn: "https://@your-server:3000/", + dsn: "https://@your-server:9090/", }); // Capture manually @@ -74,7 +74,7 @@ try { // npm install @sentry/browser Sentry.init({ - dsn: "https://@your-server:3000/", + dsn: "https://@your-server:9090/", }); ``` @@ -84,7 +84,7 @@ Sentry.init({ // pubspec.yaml: sentry_flutter: ^8.0.0 await SentryFlutter.init((options) { - options.dsn = 'https://@your-server:3000/'; + options.dsn = 'https://@your-server:9090/'; }); // Capture manually diff --git a/docs/guide/vps-deployment.md b/docs/guide/vps-deployment.md index b51fc41..7dc86b2 100644 --- a/docs/guide/vps-deployment.md +++ b/docs/guide/vps-deployment.md @@ -25,7 +25,7 @@ nano .env Yang perlu diubah di `.env`: ```bash -TRAPFALL_PORT=3000 # port yang dibuka +TRAPFALL_PORT=9090 # port yang dibuka TRAPFALL_DATABASE_URL=sqlite:/data/trapfall.db TRAPFALL_SECURE_COOKIE=false # false jika belum HTTPS, true jika sudah TRAPFALL_CORS_ORIGINS= # kosongkan jika single-server @@ -39,7 +39,7 @@ docker compose -f docker-compose.prod.yml up -d ### 3. Setup Wizard -Buka `http://VPS_IP:3000` → buat admin account → selesai. +Buka `http://VPS_IP:9090` → buat admin account → selesai. ### 4. Cek status @@ -51,7 +51,7 @@ docker compose -f docker-compose.prod.yml ps docker compose -f docker-compose.prod.yml logs -f # Health check -curl http://localhost:3000/health +curl http://localhost:9090/health ``` --- @@ -93,7 +93,7 @@ Postgres container otomatis start bersama TrapFall. docker compose -f docker-compose.prod.yml ps postgres # Check metrics -curl http://localhost:3000/metrics +curl http://localhost:9090/metrics ``` --- @@ -122,7 +122,7 @@ Buat `Caddyfile`: ```text trapfall.yourdomain.com { - reverse_proxy trapfall:3000 + reverse_proxy trapfall:9090 } ```