ArkEcosystem / core

The ARK Core Blockchain Framework. Check https://learn.ark.dev for more information.
https://ark.io
MIT License
338 stars 285 forks source link

feat(core-api): expose a list of paginated routes to the plugins when registering `api` server #3894

Closed kristjank closed 4 years ago

kristjank commented 4 years ago

Current Pagination for our core-api endpoints is hardcoded in ext.ts and is not exposed outside of core-api, so that it can be used by plugins.

Expected Behavior

Expose a method that will enable new plugins to register additional routes that require pagination. This can be done when we are registering new api endpoints within the service-provider.ts while a plugin is being loaded.

Current Behaviour

If the endpoints are not registered as paginated, the meta information is not added to API responses.

When registering new endpoints (via plugins), the paginated ones don’t get served in a standard core way with metadata and other info, that is added if the endpoint is listed in ext.ts (registered as paginated endpoint).

Possible Solution

Expose a method that will make it possible to register additional paginated routes when the custom plugins are loaded. A possible way could be via await this.app.get<Server>(identifier).register({ method to add arguments for paginated routes.

https://github.com/ArkEcosystem/core/blob/develop/packages/core-api/src/plugins/pagination/ext.ts#L14-L43

from service-provider.ts

        await this.app.get<Server>(identifier).register({
                    plugin: Handlers,
                    routes: { prefix: "/api/nft", paginated: .{IRoute...}... },
         });

Your Environment

air1one commented 4 years ago

@kristjank I merged the PR to develop, can you check if that works for you ? Then close this if it does :ok_hand:

air1one commented 4 years ago

I'll close this, if this is not fixed feel free to re-open @kristjank