hyperledger-cacti / cacti

Hyperledger Cacti is a new approach to the blockchain interoperability problem
https://wiki.hyperledger.org/display/cactus
Apache License 2.0
341 stars 282 forks source link

feat(connectors): web service endpoint decorator #2974

Open outSH opened 9 months ago

outSH commented 9 months ago

Is your feature request related to a problem? Please describe.

Describe the solution you'd like

Example

    @WebService({
        httpVerb: "post", // possibly enum
        path: "/api/v1/plugins/@hyperledger/cactus-plugin-ledger-connector-ethereum/deploy-contract",  
    })
    @WebServiceAccess(roles)
    public async deployContract(
        req: DeployContractV1Request,
    ): Promise<RunTransactionResponse> {
        // ...
    }

This would create new IWebServiceEndpoint and add it to decorated method class field this.endpoints (that can later be used by cmd-api-server to create an actual endpoint).

More benefits:

Describe alternatives you've considered

Additional context

@petermetz @takeutak @izuru0 @jagpreetsinghsasan @VRamakrishna @sandeepnRES This is just a generic idea, please let me know what you think and then I can work on PoC to make sure it works as expected.

petermetz commented 9 months ago

@outSH Sorry for the slow response! I agree with all the points!

My only thing to add is that we should make sure to test this very thoroughly with different platform builds to make sure that tooling can deal with it. It's been a few years since I last tried to do decorators (back when it was beta) and back then there was always something in the build tooling that would not play well with it (looking at you webpack/rollup/etc)