diff --git a/.zed/debug.json b/.zed/debug.json index 6f50aaf..6418b00 100644 --- a/.zed/debug.json +++ b/.zed/debug.json @@ -10,7 +10,7 @@ "mode": "debug", "program": "./cmd/gateway", "env": { - "GATEWAY_ADDR": ":8080", + "GATEWAY_ADDR": ":6001", "GATEWAY_BOOTSTRAP_PEERS": "/ip4/127.0.0.1/tcp/4001/p2p/12D3KooWSHHwEY6cga3ng7tD1rzStAU58ogQXVMX3LZJ6Gqf6dee", "GATEWAY_NAMESPACE": "default", "GATEWAY_API_KEY": "ak_iGustrsFk9H8uXpwczCATe5U:default" @@ -30,12 +30,12 @@ }, { "adapter": "Delve", - "label": "Gateway Go 8005 Port (Delve)", + "label": "Gateway Go 6001 Port (Delve)", "request": "launch", "mode": "debug", "program": "./cmd/gateway", "env": { - "GATEWAY_ADDR": ":8005", + "GATEWAY_ADDR": ":6001", "GATEWAY_BOOTSTRAP_PEERS": "/ip4/127.0.0.1/tcp/4001/p2p/12D3KooWSHHwEY6cga3ng7tD1rzStAU58ogQXVMX3LZJ6Gqf6dee", "GATEWAY_NAMESPACE": "default", "GATEWAY_API_KEY": "ak_iGustrsFk9H8uXpwczCATe5U:default" diff --git a/CHANGELOG.md b/CHANGELOG.md index 7b63783..5f4758c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,8 +8,12 @@ The format is based on [Keep a Changelog][keepachangelog] and adheres to [Semant ### Added +- Added Gateway port on install-debros-network.sh + ### Changed +- Updated Gateway port from 8080/8005 to 6001 + ### Deprecated ### Removed diff --git a/Makefile b/Makefile index 2b6200e..7292afb 100644 --- a/Makefile +++ b/Makefile @@ -7,12 +7,12 @@ test: # Gateway-focused E2E tests assume gateway and nodes are already running # Configure via env: -# GATEWAY_BASE_URL (default http://127.0.0.1:8080) +# GATEWAY_BASE_URL (default http://127.0.0.1:6001) # GATEWAY_API_KEY (required for auth-protected routes) .PHONY: test-e2e test-e2e: @echo "Running gateway E2E tests (HTTP/WS only)..." - @echo "Base URL: $${GATEWAY_BASE_URL:-http://127.0.0.1:8080}" + @echo "Base URL: $${GATEWAY_BASE_URL:-http://127.0.0.1:6001}" @test -n "$$GATEWAY_API_KEY" || (echo "GATEWAY_API_KEY must be set" && exit 1) go test -v -tags e2e ./e2e @@ -21,7 +21,7 @@ test-e2e: .PHONY: build clean test run-node run-node2 run-node3 run-example deps tidy fmt vet lint clear-ports -VERSION := 0.42.4-beta +VERSION := 0.42.5-beta COMMIT ?= $(shell git rev-parse --short HEAD 2>/dev/null || echo unknown) DATE ?= $(shell date -u +%Y-%m-%dT%H:%M:%SZ) LDFLAGS := -X 'main.version=$(VERSION)' -X 'main.commit=$(COMMIT)' -X 'main.date=$(DATE)' diff --git a/README.md b/README.md index a5c7f1f..aced638 100644 --- a/README.md +++ b/README.md @@ -379,7 +379,7 @@ The gateway can be configured via environment variables: ```bash # Basic Configuration -export GATEWAY_ADDR="0.0.0.0:8080" +export GATEWAY_ADDR="0.0.0.0:6001" export GATEWAY_NAMESPACE="my-app" export GATEWAY_BOOTSTRAP_PEERS="/ip4/127.0.0.1/tcp/4001/p2p/YOUR_PEER_ID" @@ -533,11 +533,11 @@ resp, err := http.DefaultClient.Do(req) #### Wallet Authentication Flow ```bash # 1. Get challenge (automatic) -curl -X POST http://localhost:8080/v1/auth/challenge +curl -X POST http://localhost:6001/v1/auth/challenge # 2. Sign challenge with wallet (handled by client) # 3. Verify signature (automatic) -curl -X POST http://localhost:8080/v1/auth/verify \ +curl -X POST http://localhost:6001/v1/auth/verify \ -H "Content-Type: application/json" \ -d '{"wallet":"0x...","nonce":"...","signature":"0x..."}' ``` @@ -547,7 +547,7 @@ curl -X POST http://localhost:8080/v1/auth/verify \ #### Real-time Messaging ```javascript // WebSocket connection -const ws = new WebSocket('ws://localhost:8080/v1/pubsub/ws?topic=chat'); +const ws = new WebSocket('ws://localhost:6001/v1/pubsub/ws?topic=chat'); ws.onmessage = (event) => { console.log('Received:', event.data); @@ -661,8 +661,8 @@ export LOG_LEVEL=debug ./bin/network-cli pubsub subscribe test 10s # Gateway health checks -curl http://localhost:8080/health -curl http://localhost:8080/v1/status +curl http://localhost:6001/health +curl http://localhost:6001/v1/status ``` ### Service Logs diff --git a/cmd/gateway/config.go b/cmd/gateway/config.go index af36b41..6b03c20 100644 --- a/cmd/gateway/config.go +++ b/cmd/gateway/config.go @@ -39,7 +39,7 @@ func getEnvBoolDefault(key string, def bool) bool { // parseGatewayConfig parses flags and environment variables into GatewayConfig. // Priority: flags > env > defaults. func parseGatewayConfig(logger *logging.ColoredLogger) *gateway.Config { - addr := flag.String("addr", getEnvDefault("GATEWAY_ADDR", ":8080"), "HTTP listen address (e.g., :8080)") + addr := flag.String("addr", getEnvDefault("GATEWAY_ADDR", ":6001"), "HTTP listen address (e.g., :6001)") ns := flag.String("namespace", getEnvDefault("GATEWAY_NAMESPACE", "default"), "Client namespace for scoping resources") peers := flag.String("bootstrap-peers", getEnvDefault("GATEWAY_BOOTSTRAP_PEERS", ""), "Comma-separated bootstrap peers for network client") diff --git a/e2e/gateway_e2e_test.go b/e2e/gateway_e2e_test.go index ef2ba6b..6a99e98 100644 --- a/e2e/gateway_e2e_test.go +++ b/e2e/gateway_e2e_test.go @@ -34,7 +34,7 @@ func requireAPIKey(t *testing.T) string { } func gatewayBaseURL() string { - return getEnv("GATEWAY_BASE_URL", "http://127.0.0.1:8080") + return getEnv("GATEWAY_BASE_URL", "http://127.0.0.1:6001") } func httpClient() *http.Client { diff --git a/examples/sdk-typescript/README.md b/examples/sdk-typescript/README.md index 6e2bc73..1e78797 100644 --- a/examples/sdk-typescript/README.md +++ b/examples/sdk-typescript/README.md @@ -6,7 +6,7 @@ Usage: ```bash npm i -export GATEWAY_BASE_URL=http://127.0.0.1:8080 +export GATEWAY_BASE_URL=http://127.0.0.1:6001 export GATEWAY_API_KEY=your_api_key ``` diff --git a/openapi/gateway.yaml b/openapi/gateway.yaml index 7ad1702..6150344 100644 --- a/openapi/gateway.yaml +++ b/openapi/gateway.yaml @@ -4,7 +4,7 @@ info: version: 0.40.0 description: REST API over the DeBros Network client for storage, database, and pubsub. servers: - - url: http://localhost:8080 + - url: http://localhost:6001 security: - ApiKeyAuth: [] - BearerAuth: [] diff --git a/pkg/auth/credentials.go b/pkg/auth/credentials.go index 7176eb6..923eb1d 100644 --- a/pkg/auth/credentials.go +++ b/pkg/auth/credentials.go @@ -173,7 +173,7 @@ func GetDefaultGatewayURL() string { if envURL := os.Getenv("DEBROS_GATEWAY"); envURL != "" { return envURL } - return "http://localhost:8005" + return "http://localhost:6001" } // HasValidCredentials checks if there are valid credentials for the default gateway diff --git a/scripts/install-debros-network.sh b/scripts/install-debros-network.sh index f0514f1..a59ca2d 100755 --- a/scripts/install-debros-network.sh +++ b/scripts/install-debros-network.sh @@ -21,6 +21,7 @@ REPO_URL="https://github.com/DeBrosOfficial/network.git" MIN_GO_VERSION="1.21" NODE_PORT="4001" RQLITE_PORT="5001" +GATEWAY_PORT="6001" RAFT_PORT="7001" UPDATE_MODE=false NON_INTERACTIVE=false @@ -249,7 +250,7 @@ install_rqlite() { } check_ports() { - local ports=($NODE_PORT $RQLITE_PORT $RAFT_PORT) + local ports=($NODE_PORT $RQLITE_PORT $RAFT_PORT $GATEWAY_PORT) for port in "${ports[@]}"; do if sudo netstat -tuln 2>/dev/null | grep -q ":$port " || ss -tuln 2>/dev/null | grep -q ":$port "; then error "Port $port is already in use. Please free it up and try again." @@ -427,7 +428,7 @@ configure_firewall() { log "Configuring firewall rules..." if command -v ufw &> /dev/null; then log "Adding UFW rules for DeBros Network ports..." - for port in $NODE_PORT $RQLITE_PORT $RAFT_PORT; do + for port in $NODE_PORT $RQLITE_PORT $RAFT_PORT $GATEWAY_PORT; do if ! sudo ufw allow $port; then error "Failed to allow port $port" exit 1 @@ -562,6 +563,7 @@ main() { log "${GREEN}Node Port:${NOCOLOR} ${CYAN}$NODE_PORT${NOCOLOR}" log "${GREEN}RQLite Port:${NOCOLOR} ${CYAN}$RQLITE_PORT${NOCOLOR}" log "${GREEN}Raft Port:${NOCOLOR} ${CYAN}$RAFT_PORT${NOCOLOR}" + log "${GREEN}Gateway Port:${NOCOLOR} ${CYAN}$GATEWAY_PORT${NOCOLOR}" log "${BLUE}==================================================${NOCOLOR}" log "${GREEN}Management Commands:${NOCOLOR}" log "${CYAN} - sudo systemctl status debros-node${NOCOLOR} (Check status)"