Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(DAL) Simplify api endpoint #1865

Merged
merged 3 commits into from
Jul 22, 2024
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
2 changes: 1 addition & 1 deletion node/pkg/dal/api/route.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
)

func Routes(router fiber.Router) {
api := router.Group("/dal")
api := router.Group("")

api.Get("/symbols", getSymbols)
api.Get("/latest-data-feeds/all", getAllLatestFeeds)
Expand Down
2 changes: 1 addition & 1 deletion node/pkg/dal/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ func Run(ctx context.Context) error {
_ = app.Shutdown()
}()

v1 := app.Group("/api/v1")
v1 := app.Group("")
v1.Get("/", func(c *fiber.Ctx) error {
return c.SendString("Orakl Node DAL API")
})
Expand Down
10 changes: 5 additions & 5 deletions node/pkg/dal/tests/api_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ func TestApiGetLatestAll(t *testing.T) {
}

time.Sleep(10 * time.Millisecond)
result, err := request.Request[[]common.OutgoingSubmissionData](request.WithEndpoint("http://localhost:8090/api/v1/dal/latest-data-feeds/all"), request.WithHeaders(map[string]string{"X-API-Key": testItems.ApiKey}))
result, err := request.Request[[]common.OutgoingSubmissionData](request.WithEndpoint("http://localhost:8090/latest-data-feeds/all"), request.WithHeaders(map[string]string{"X-API-Key": testItems.ApiKey}))
if err != nil {
t.Fatalf("error getting latest data: %v", err)
}
Expand Down Expand Up @@ -89,14 +89,14 @@ func TestShouldFailWithoutApiKey(t *testing.T) {
}()

go testItems.App.Listen(":8090")
resp, err := request.RequestRaw(request.WithEndpoint("http://localhost:8090/api/v1"))
resp, err := request.RequestRaw(request.WithEndpoint("http://localhost:8090/"))
if err != nil {
t.Fatalf("error getting latest data: %v", err)
}

assert.Equal(t, 200, resp.StatusCode)

result, err := request.RequestRaw(request.WithEndpoint("http://localhost:8090/api/v1/dal/latest-data-feeds/test-aggregate"))
result, err := request.RequestRaw(request.WithEndpoint("http://localhost:8090/latest-data-feeds/test-aggregate"))

if err != nil {
t.Fatalf("error getting latest data: %v", err)
Expand Down Expand Up @@ -136,7 +136,7 @@ func TestApiGetLatest(t *testing.T) {

time.Sleep(10 * time.Millisecond)

result, err := request.Request[[]common.OutgoingSubmissionData](request.WithEndpoint("http://localhost:8090/api/v1/dal/latest-data-feeds/test-aggregate"), request.WithHeaders(map[string]string{"X-API-Key": testItems.ApiKey}))
result, err := request.Request[[]common.OutgoingSubmissionData](request.WithEndpoint("http://localhost:8090/latest-data-feeds/test-aggregate"), request.WithHeaders(map[string]string{"X-API-Key": testItems.ApiKey}))
if err != nil {
t.Fatalf("error getting latest data: %v", err)
}
Expand All @@ -163,7 +163,7 @@ func TestApiWebsocket(t *testing.T) {

go testItems.App.Listen(":8090")

conn, err := wss.NewWebsocketHelper(ctx, wss.WithEndpoint("ws://localhost:8090/api/v1/dal/ws"), wss.WithRequestHeaders(headers))
conn, err := wss.NewWebsocketHelper(ctx, wss.WithEndpoint("ws://localhost:8090/ws"), wss.WithRequestHeaders(headers))
if err != nil {
t.Fatalf("error creating websocket helper: %v", err)
}
Expand Down
2 changes: 1 addition & 1 deletion node/pkg/dal/tests/collector_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ func TestCollectorStream(t *testing.T) {
assert.True(t, collector.IsRunning)

headers := map[string]string{"X-API-Key": testItems.ApiKey}
conn, err := wss.NewWebsocketHelper(ctx, wss.WithEndpoint("ws://localhost:8090/api/v1/dal/ws"), wss.WithRequestHeaders(headers))
conn, err := wss.NewWebsocketHelper(ctx, wss.WithEndpoint("ws://localhost:8090/ws"), wss.WithRequestHeaders(headers))
if err != nil {
t.Fatalf("error creating websocket helper: %v", err)
}
Expand Down
2 changes: 1 addition & 1 deletion node/pkg/dal/tests/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ func setup(ctx context.Context) (func() error, *TestItems, error) {
testItems.Controller = apiController
testItems.MockAdmin = mockAdminServer

v1 := app.Group("/api/v1")
v1 := app.Group("")
v1.Get("/", func(c *fiber.Ctx) error {
return c.SendString("Orakl Node DAL API")
})
Expand Down
2 changes: 1 addition & 1 deletion node/pkg/dal/utils/initializer/initializer.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ func CustomStackTraceHandler(_ *fiber.Ctx, e interface{}) {

func authFilter(c *fiber.Ctx) bool {
originalURL := strings.ToLower(c.OriginalURL())
return originalURL == "/api/v1"
return originalURL == "/"
}

func validator(c *fiber.Ctx, s string) (bool, error) {
Expand Down
2 changes: 1 addition & 1 deletion node/pkg/dal/utils/stats/stats.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ func StatsMiddleware(c *fiber.Ctx) error {
}
duration := time.Since(start)

if c.Path() == "/api/v1" {
if c.Path() == "/" {
return nil
}

Expand Down
2 changes: 1 addition & 1 deletion sentinel/pkg/checker/health/baobab_healthcheck.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
},
{
"name": "orakl-dal",
"url": "http://orakl-dal.orakl.svc.cluster.local:80/api/v1"
"url": "http://orakl-dal.orakl.svc.cluster.local:80/"
},
{
"name": "orakl-delegator",
Expand Down
4 changes: 4 additions & 0 deletions sentinel/pkg/checker/health/cypress_healthcheck.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@
"name": "orakl-boot-api",
"url": "http://orakl-boot-api.orakl.svc.cluster.local:5050/api/v1/"
},
{
"name": "orakl-dal",
"url": "http://orakl-dal.orakl.svc.cluster.local:80/"
},
{
"name": "orakl-delegator",
"url": "http://orakl-delegator.orakl.svc.cluster.local:80/api/v1/"
Expand Down