0.7.0 • Published 2 years ago

@unparallel/smartclide-backend-connector v0.7.0

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

Overview

This module is a wrapper for swagger-client that simplifies the process of making calls to the SmartCLIDE DB API, given its swagger description and a Keycloak Bearer Authorization Token.

The current version provides:

  • call method that takes an object with the request configuration and returns the response from the API. The configuration object has the following properties:
PropertyDescriptionRequired for
operationIDID of the operation according to the swagger descriptionAll requests
parametersObject containing the parameters required by the request (e.g., { userId: "<userId>" } to send the userId to the /{userId} endpoint)When demanded by the request
requestBodyObject containing the data to be sent to the API, in the request body (e.g., { id: "<id>", email: "<email>", team_id: "<team_id>" } to send the details of the user to be created/updated)POST and PUT requests
tokenKeycloak Bearer Authorization TokenAll requests that require authentication
  • exists method that returns a boolean indicating whether there is a document of the given entity with the provided ID. The parameters are:
ParameterDescription
entityEntity in which to search for the given ID
idID of the document to be searched for
tokenKeycloak Bearer Authorization Token

How to use?

Add as a dependency to the package.json

{
  "dependencies": {
    "@unparallel/smartclide-backend-connector": "latest"
  }
}

Install dependencies

npm install

Usage Example

// Import the module
import SmartCLIDEBackendConnector from "@unparallel/smartclide-backend-connector";

// Instantiate the connector providing the URL of the swagger description of the API
let connector = await new SmartCLIDEBackendConnector("<swaggerURL>");

// Create a configuration object with the required properties
let configuration = {
    operationID: "<operationID>",
    parameters: { userId: "<userID>" },
    requestBody: {
        id: "<id>",
        email: "<email>",
        team_id: "<team_id>"
    },
    token: "<Keycloak Token>"
};

// Make the request
let result = await connector.call(configuration);

// Log the response
console.log(result);

License

MIT

0.5.0

2 years ago

0.7.0

2 years ago

0.6.0

2 years ago

0.4.0

2 years ago

0.3.0

2 years ago

0.2.0

2 years ago

0.1.0

2 years ago