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

refactor: Moved external APIs out of node #2069

Merged
merged 3 commits into from
Sep 22, 2023
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 apps/chat2bridge/chat2bridge.nim
Original file line number Diff line number Diff line change
Expand Up @@ -217,11 +217,11 @@ proc stop*(cmb: Chat2MatterBridge) {.async.} =
when isMainModule:
import
../../../waku/common/utils/nat,
../../waku/node/message_cache,
../../waku/node/jsonrpc/debug/handlers as debug_api,
../../waku/node/jsonrpc/filter/handlers as filter_api,
../../waku/node/jsonrpc/relay/handlers as relay_api,
../../waku/node/jsonrpc/store/handlers as store_api
../../waku/waku_api/message_cache,
../../waku/waku_api/jsonrpc/debug/handlers as debug_api,
../../waku/waku_api/jsonrpc/filter/handlers as filter_api,
../../waku/waku_api/jsonrpc/relay/handlers as relay_api,
../../waku/waku_api/jsonrpc/store/handlers as store_api


proc startV2Rpc(node: WakuNode, rpcServer: RpcHttpServer, conf: Chat2MatterbridgeConf) {.raises: [Exception].} =
Expand Down
34 changes: 17 additions & 17 deletions apps/wakunode2/app.nim
Original file line number Diff line number Diff line change
Expand Up @@ -38,26 +38,25 @@ import
../../waku/waku_lightpush,
../../waku/waku_filter,
../../waku/waku_filter_v2,
../../waku/waku_filter_v2/client as waku_filter_client,
./wakunode2_validator_signed,
./internal_config,
./external_config
import
../../waku/node/message_cache,
../../waku/node/rest/server,
../../waku/node/rest/debug/handlers as rest_debug_api,
../../waku/node/rest/relay/handlers as rest_relay_api,
../../waku/node/rest/relay/topic_cache,
../../waku/node/rest/filter/legacy_handlers as rest_legacy_filter_api,
../../waku/node/rest/filter/handlers as rest_filter_api,
../../waku/node/rest/store/handlers as rest_store_api,
../../waku/node/rest/health/handlers as rest_health_api,
../../waku/node/rest/lightpush/handlers as rest_lightpush_api,
../../waku/node/jsonrpc/admin/handlers as rpc_admin_api,
../../waku/node/jsonrpc/debug/handlers as rpc_debug_api,
../../waku/node/jsonrpc/filter/handlers as rpc_filter_api,
../../waku/node/jsonrpc/relay/handlers as rpc_relay_api,
../../waku/node/jsonrpc/store/handlers as rpc_store_api
../../waku/waku_api/message_cache,
../../waku/waku_api/rest/server,
../../waku/waku_api/rest/debug/handlers as rest_debug_api,
../../waku/waku_api/rest/relay/handlers as rest_relay_api,
../../waku/waku_api/rest/relay/topic_cache,
../../waku/waku_api/rest/filter/legacy_handlers as rest_legacy_filter_api,
../../waku/waku_api/rest/filter/handlers as rest_filter_api,
../../waku/waku_api/rest/lightpush/handlers as rest_lightpush_api,
../../waku/waku_api/rest/store/handlers as rest_store_api,
../../waku/waku_api/rest/health/handlers as rest_health_api,
../../waku/waku_api/jsonrpc/admin/handlers as rpc_admin_api,
../../waku/waku_api/jsonrpc/debug/handlers as rpc_debug_api,
../../waku/waku_api/jsonrpc/filter/handlers as rpc_filter_api,
../../waku/waku_api/jsonrpc/relay/handlers as rpc_relay_api,
../../waku/waku_api/jsonrpc/store/handlers as rpc_store_api

logScope:
topics = "wakunode app"
Expand Down Expand Up @@ -591,7 +590,8 @@ proc startRestServer(app: App, address: ValidIpAddress, port: Port, conf: WakuNo
## Store REST API
installStoreApiHandlers(server.router, app.node)

installLightPushRequestHandler(server.router, app.node)
## Light push API
rest_lightpush_api.installLightPushRequestHandler(server.router, app.node)

server.start()
info "Starting REST HTTP server", url = "http://" & $address & ":" & $port & "/"
Expand Down
2 changes: 1 addition & 1 deletion tests/test_message_cache.nim
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import
chronicles
import
../../waku/waku_core,
../../waku/node/message_cache,
../../waku/waku_api/message_cache,
./testlib/common,
./testlib/wakucore

Expand Down
4 changes: 2 additions & 2 deletions tests/wakunode_jsonrpc/test_jsonrpc_admin.nim
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ import
../../../waku/waku_core,
../../../waku/node/peer_manager,
../../../waku/waku_node,
../../../waku/node/jsonrpc/admin/handlers as admin_api,
../../../waku/node/jsonrpc/admin/client as admin_api_client,
../../../waku/waku_api/jsonrpc/admin/handlers as admin_api,
../../../waku/waku_api/jsonrpc/admin/client as admin_api_client,
../../../waku/waku_relay,
../../../waku/waku_archive,
../../../waku/waku_archive/driver/queue_driver,
Expand Down
4 changes: 2 additions & 2 deletions tests/wakunode_jsonrpc/test_jsonrpc_debug.nim
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ import
import
../../../waku/node/peer_manager,
../../../waku/waku_node,
../../../waku/node/jsonrpc/debug/handlers as debug_api,
../../../waku/node/jsonrpc/debug/client as debug_api_client,
../../../waku/waku_api/jsonrpc/debug/handlers as debug_api,
../../../waku/waku_api/jsonrpc/debug/client as debug_api_client,
../testlib/common,
../testlib/wakucore,
../testlib/wakunode
Expand Down
6 changes: 3 additions & 3 deletions tests/wakunode_jsonrpc/test_jsonrpc_filter.nim
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ import
../../../waku/waku_core,
../../../waku/node/peer_manager,
../../../waku/waku_node,
../../../waku/node/message_cache,
../../../waku/node/jsonrpc/filter/handlers as filter_api,
../../../waku/node/jsonrpc/filter/client as filter_api_client,
../../../waku/waku_api/message_cache,
../../../waku/waku_api/jsonrpc/filter/handlers as filter_api,
../../../waku/waku_api/jsonrpc/filter/client as filter_api_client,
../../../waku/waku_filter,
../../../waku/waku_filter/rpc,
../../../waku/waku_filter/client,
Expand Down
6 changes: 3 additions & 3 deletions tests/wakunode_jsonrpc/test_jsonrpc_relay.nim
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ import
../../../waku/common/base64,
../../../waku/waku_core,
../../../waku/node/peer_manager,
../../../waku/node/message_cache,
../../../waku/waku_api/message_cache,
../../../waku/waku_node,
../../../waku/node/jsonrpc/relay/handlers as relay_api,
../../../waku/node/jsonrpc/relay/client as relay_api_client,
../../../waku/waku_api/jsonrpc/relay/handlers as relay_api,
../../../waku/waku_api/jsonrpc/relay/client as relay_api_client,
../../../waku/waku_core,
../../../waku/waku_relay,
../../../waku/waku_rln_relay,
Expand Down
4 changes: 2 additions & 2 deletions tests/wakunode_jsonrpc/test_jsonrpc_store.nim
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ import
../../../waku/waku_core,
../../../waku/node/peer_manager,
../../../waku/waku_node,
../../../waku/node/jsonrpc/store/handlers as store_api,
../../../waku/node/jsonrpc/store/client as store_api_client,
../../../waku/waku_api/jsonrpc/store/handlers as store_api,
../../../waku/waku_api/jsonrpc/store/client as store_api_client,
../../../waku/waku_archive,
../../../waku/waku_archive/driver/queue_driver,
../../../waku/waku_store,
Expand Down
10 changes: 5 additions & 5 deletions tests/wakunode_rest/test_rest_debug.nim
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ import
import
../../waku/waku_node,
../../waku/node/waku_node as waku_node2, # TODO: Remove after moving `git_version` to the app code.
../../waku/node/rest/server,
../../waku/node/rest/client,
../../waku/node/rest/responses,
../../waku/node/rest/debug/handlers as debug_api,
../../waku/node/rest/debug/client as debug_api_client,
../../waku/waku_api/rest/server,
../../waku/waku_api/rest/client,
../../waku/waku_api/rest/responses,
../../waku/waku_api/rest/debug/handlers as debug_api,
../../waku/waku_api/rest/debug/client as debug_api_client,
../testlib/common,
../testlib/wakucore,
../testlib/wakunode
Expand Down
4 changes: 2 additions & 2 deletions tests/wakunode_rest/test_rest_debug_serdes.nim
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import
testutils/unittests,
json_serialization
import
../../waku/node/rest/serdes,
../../waku/node/rest/debug/types
../../waku/waku_api/rest/serdes,
../../waku/waku_api/rest/debug/types


suite "Waku v2 REST API - Debug - serialization":
Expand Down
20 changes: 10 additions & 10 deletions tests/wakunode_rest/test_rest_filter.nim
Original file line number Diff line number Diff line change
Expand Up @@ -8,24 +8,24 @@ import
presto, presto/client as presto_client,
libp2p/crypto/crypto
import
../../waku/node/message_cache,
../../waku/waku_api/message_cache,
../../waku/common/base64,
../../waku/waku_core,
../../waku/waku_node,
../../waku/node/peer_manager,
../../waku/waku_filter,
../../waku/node/rest/server,
../../waku/node/rest/client,
../../waku/node/rest/responses,
../../waku/node/rest/filter/types,
../../waku/node/rest/filter/handlers as filter_api,
../../waku/node/rest/filter/client as filter_api_client,
../../waku/waku_api/rest/server,
../../waku/waku_api/rest/client,
../../waku/waku_api/rest/responses,
../../waku/waku_api/rest/filter/types,
../../waku/waku_api/rest/filter/handlers as filter_api,
../../waku/waku_api/rest/filter/client as filter_api_client,
../../waku/waku_relay,
../../waku/waku_filter_v2/subscriptions,
../../waku/waku_filter_v2/common,
../../waku/node/rest/relay/topic_cache,
../../waku/node/rest/relay/handlers as relay_api,
../../waku/node/rest/relay/client as relay_api_client,
../../waku/waku_api/rest/relay/topic_cache,
../../waku/waku_api/rest/relay/handlers as relay_api,
../../waku/waku_api/rest/relay/client as relay_api_client,
../testlib/wakucore,
../testlib/wakunode

Expand Down
10 changes: 5 additions & 5 deletions tests/wakunode_rest/test_rest_health.nim
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@ import
import
../../waku/waku_node,
../../waku/node/waku_node as waku_node2, # TODO: Remove after moving `git_version` to the app code.
../../waku/node/rest/server,
../../waku/node/rest/client,
../../waku/node/rest/responses,
../../waku/node/rest/health/handlers as health_api,
../../waku/node/rest/health/client as health_api_client,
../../waku/waku_api/rest/server,
../../waku/waku_api/rest/client,
../../waku/waku_api/rest/responses,
../../waku/waku_api/rest/health/handlers as health_api,
../../waku/waku_api/rest/health/client as health_api_client,
../../waku/waku_rln_relay,
../testlib/common,
../testlib/testutils,
Expand Down
14 changes: 7 additions & 7 deletions tests/wakunode_rest/test_rest_legacy_filter.nim
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,18 @@ import
presto, presto/client as presto_client,
libp2p/crypto/crypto
import
../../waku/node/message_cache,
../../waku/waku_api/message_cache,
../../waku/common/base64,
../../waku/waku_core,
../../waku/waku_node,
../../waku/node/peer_manager,
../../waku/waku_filter,
../../waku/node/rest/server,
../../waku/node/rest/client,
../../waku/node/rest/responses,
../../waku/node/rest/filter/types,
../../waku/node/rest/filter/legacy_handlers as filter_api,
../../waku/node/rest/filter/legacy_client as filter_api_client,
../../waku/waku_api/rest/server,
../../waku/waku_api/rest/client,
../../waku/waku_api/rest/responses,
../../waku/waku_api/rest/filter/types,
../../waku/waku_api/rest/filter/legacy_handlers as filter_api,
../../waku/waku_api/rest/filter/legacy_client as filter_api_client,
../../waku/waku_relay,
../testlib/wakucore,
../testlib/wakunode
Expand Down
14 changes: 7 additions & 7 deletions tests/wakunode_rest/test_rest_lightpush.nim
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,18 @@ import
libp2p/crypto/crypto

import
../../waku/node/message_cache,
../../waku/waku_api/message_cache,
../../waku/common/base64,
../../waku/waku_core,
../../waku/waku_node,
../../waku/node/peer_manager,
../../waku/waku_lightpush,
../../waku/node/rest/server,
../../waku/node/rest/client,
../../waku/node/rest/responses,
../../waku/node/rest/lightpush/types,
../../waku/node/rest/lightpush/handlers as lightpush_api,
../../waku/node/rest/lightpush/client as lightpush_api_client,
../../waku/waku_api/rest/server,
../../waku/waku_api/rest/client,
../../waku/waku_api/rest/responses,
../../waku/waku_api/rest/lightpush/types,
../../waku/waku_api/rest/lightpush/handlers as lightpush_api,
../../waku/waku_api/rest/lightpush/client as lightpush_api_client,
../../waku/waku_relay,
../testlib/wakucore,
../testlib/wakunode
Expand Down
14 changes: 7 additions & 7 deletions tests/wakunode_rest/test_rest_relay.nim
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@ import
../../waku/common/base64,
../../waku/waku_core,
../../waku/waku_node,
../../waku/node/rest/server,
../../waku/node/rest/client,
../../waku/node/rest/responses,
../../waku/node/rest/relay/types,
../../waku/node/rest/relay/handlers as relay_api,
../../waku/node/rest/relay/client as relay_api_client,
../../waku/node/rest/relay/topic_cache,
../../waku/waku_api/rest/server,
../../waku/waku_api/rest/client,
../../waku/waku_api/rest/responses,
../../waku/waku_api/rest/relay/types,
../../waku/waku_api/rest/relay/handlers as relay_api,
../../waku/waku_api/rest/relay/client as relay_api_client,
../../waku/waku_api/rest/relay/topic_cache,
../../waku/waku_relay,
../../../waku/waku_rln_relay,
../testlib/wakucore,
Expand Down
4 changes: 2 additions & 2 deletions tests/wakunode_rest/test_rest_relay_serdes.nim
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ import
json_serialization
import
../../waku/common/base64,
../../waku/node/rest/serdes,
../../waku/node/rest/relay/types,
../../waku/waku_api/rest/serdes,
../../waku/waku_api/rest/relay/types,
../../waku/waku_core


Expand Down
4 changes: 2 additions & 2 deletions tests/wakunode_rest/test_rest_serdes.nim
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import
unittest2,
json_serialization
import
../../waku/node/rest/serdes,
../../waku/node/rest/debug/types
../../waku/waku_api/rest/serdes,
../../waku/waku_api/rest/debug/types


# TODO: Decouple this test suite from the `debug_api` module by defining
Expand Down
12 changes: 6 additions & 6 deletions tests/wakunode_rest/test_rest_store.nim
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@ import
../../../waku/waku_core/time,
../../../waku/waku_node,
../../../waku/node/peer_manager,
../../../waku/node/rest/server,
../../../waku/node/rest/client,
../../../waku/node/rest/responses,
../../../waku/node/rest/store/handlers as store_api,
../../../waku/node/rest/store/client as store_api_client,
../../../waku/node/rest/store/types,
../../../waku/waku_api/rest/server,
../../../waku/waku_api/rest/client,
../../../waku/waku_api/rest/responses,
../../../waku/waku_api/rest/store/handlers as store_api,
../../../waku/waku_api/rest/store/client as store_api_client,
../../../waku/waku_api/rest/store/types,
../../../waku/waku_archive,
../../../waku/waku_archive/driver/queue_driver,
../../../waku/waku_store as waku_store,
Expand Down
5 changes: 1 addition & 4 deletions waku/node/waku_node.nim
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import
libp2p/protocols/connectivity/autonat/client,
libp2p/protocols/connectivity/autonat/service,
libp2p/protocols/rendezvous,
libp2p/nameresolving/nameresolver,
libp2p/builders,
libp2p/transports/tcptransport,
libp2p/transports/wstransport
Expand All @@ -41,9 +40,7 @@ import
../waku_peer_exchange,
../waku_rln_relay,
./config,
./peer_manager,
./waku_switch,
./rest/relay/topic_cache
./peer_manager


declarePublicCounter waku_node_messages, "number of messages received", ["type"]
Expand Down
9 changes: 9 additions & 0 deletions waku/waku_api.nim
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import
./waku_api/message_cache,
./waku_api/rest,
./waku_api/json_rpc

export
message_cache,
rest,
jsonrpc
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ import
../../../waku_store,
../../../waku_filter,
../../../waku_relay,
../../peer_manager,
../../waku_node,
../../../waku_node,
../../../node/peer_manager,
./types


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import
std/[os, strutils],
json_rpc/rpcclient
import
../../waku_node
../../../waku_node

template sourceDir: string = currentSourcePath.rsplit(DirSep, 1)[0]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import
chronicles,
json_rpc/rpcserver
import
../../waku_node
../../../waku_node

logScope:
topics = "waku node jsonrpc debug_api"
Expand Down
Loading
Loading