Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -136,15 +136,15 @@ enum SupernodeEventType {

## HTTP Gateway

The supernode provides an HTTP gateway that exposes the gRPC services via REST API. The gateway runs on a separate port 8092
The supernode provides an HTTP gateway that exposes the gRPC services via REST API. The gateway runs on a separate port 8002

### Endpoints

#### GET /api/v1/status
Returns the current supernode status including system resources (CPU, memory, storage) and service information.

```bash
curl http://localhost:8092/api/v1/status
curl http://localhost:8002/api/v1/status
```

Response:
Expand Down Expand Up @@ -198,7 +198,7 @@ Response:
Returns the list of available services on the supernode.

```bash
curl http://localhost:8092/api/v1/services
curl http://localhost:8002/api/v1/services
```

Response:
Expand All @@ -214,8 +214,8 @@ The gateway automatically translates between HTTP/JSON and gRPC/protobuf formats

The gateway provides interactive API documentation via Swagger UI:

- **Swagger UI**: http://localhost:8092/swagger-ui/
- **OpenAPI Spec**: http://localhost:8092/swagger.json
- **Swagger UI**: http://localhost:8002/swagger-ui/
- **OpenAPI Spec**: http://localhost:8002/swagger.json

The Swagger UI provides an interactive interface to explore and test all available API endpoints.

Expand Down
8 changes: 4 additions & 4 deletions supernode/node/supernode/gateway/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import (
)

// DefaultGatewayPort is an uncommon port for internal gateway use
const DefaultGatewayPort = 8092
const DefaultGatewayPort = 8002

// Server represents the HTTP gateway server
type Server struct {
Expand Down Expand Up @@ -49,8 +49,8 @@ func (s *Server) Run(ctx context.Context) error {
// Create gRPC-Gateway mux with custom JSON marshaler options
mux := runtime.NewServeMux(
runtime.WithMarshalerOption(runtime.MIMEWildcard, &runtime.JSONPb{
EmitDefaults: true, // This ensures zero values are included
OrigName: true, // Use original proto field names
EmitDefaults: true, // This ensures zero values are included
OrigName: true, // Use original proto field names
}),
)

Expand Down Expand Up @@ -123,4 +123,4 @@ func (s *Server) corsMiddleware(h http.Handler) http.Handler {

h.ServeHTTP(w, r)
})
}
}
4 changes: 2 additions & 2 deletions supernode/services/verifier/verifier.go
Original file line number Diff line number Diff line change
Expand Up @@ -196,10 +196,10 @@ func (cv *ConfigVerifier) checkPortsAvailable(result *VerificationResult) {
})
}

// Check gateway port (use configured port or default port 8092)
// Check gateway port (use configured port or default port 8002)
gatewayPort := int(cv.config.SupernodeConfig.GatewayPort)
if gatewayPort == 0 {
gatewayPort = 8092 // Default gateway port (same as gateway.DefaultGatewayPort)
gatewayPort = 8002 // Default gateway port (same as gateway.DefaultGatewayPort)
}

if !cv.isPortAvailable(cv.config.SupernodeConfig.Host, gatewayPort) {
Expand Down
16 changes: 8 additions & 8 deletions supernode/services/verifier/verifier_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ func TestVerificationResult_Summary(t *testing.T) {
{
name: "warning message",
result: &VerificationResult{
Valid: true,
Valid: true,
Errors: []ConfigError{},
Warnings: []ConfigError{
{
Expand Down Expand Up @@ -161,7 +161,7 @@ func TestConfigVerifier_isPortAvailable(t *testing.T) {
Host: "127.0.0.1",
},
}

verifier := NewConfigVerifier(cfg, nil, nil).(*ConfigVerifier)

// Test available port
Expand Down Expand Up @@ -225,8 +225,8 @@ func TestConfigVerifier_checkPortsAvailable(t *testing.T) {
}

func TestConfigVerifier_checkPortsAvailable_DefaultGatewayPort(t *testing.T) {
// Create a listener to occupy the default gateway port 8092
listener, err := net.Listen("tcp", "127.0.0.1:8092")
// Create a listener to occupy the default gateway port 8002
listener, err := net.Listen("tcp", "127.0.0.1:8002")
assert.NoError(t, err)
defer listener.Close()

Expand All @@ -236,7 +236,7 @@ func TestConfigVerifier_checkPortsAvailable_DefaultGatewayPort(t *testing.T) {
KeyName: "test-key",
Host: "127.0.0.1",
Port: 4444, // Available port
GatewayPort: 0, // Not configured, should use default 8092
GatewayPort: 0, // Not configured, should use default 8002
},
P2PConfig: config.P2PConfig{
Port: 4445, // Available port
Expand All @@ -256,6 +256,6 @@ func TestConfigVerifier_checkPortsAvailable_DefaultGatewayPort(t *testing.T) {
assert.False(t, result.IsValid())
assert.Len(t, result.Errors, 1)
assert.Equal(t, "gateway_port", result.Errors[0].Field)
assert.Equal(t, "8092", result.Errors[0].Actual)
assert.Contains(t, result.Errors[0].Message, "Port 8092 is already in use")
}
assert.Equal(t, "8002", result.Errors[0].Actual)
assert.Contains(t, result.Errors[0].Message, "Port 8002 is already in use")
}