npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

kyma-client-connector

v0.0.4

Published

Kyma Client Connector for Nodejs

Downloads

3

Readme

Welcome to Kyma-client-connector!

The kyma-client-connector helps to integrate your nodejs application with kyma by allowing you to register your application to kyma application connector with a single command, register api, register events, fetch metadata, and send events to kyma in a simplified way.

This library is in alpha stage, but it already supports the most important functionalitties of kyma application connector, there is much more to come, keep updating your library dependencies with some frequency.

Installation

In order to install kyma-client-connector, please run the command below in your project root folder:

npm i kyma-client-connector

Once the library is installed, import the library inside your project:

kymaConnector = require('kyma-client-connector');

Commands

Below are the list of commands currently supported by the library

registerApp

Register app is the first step to connect your nodejs application to kyma application connector, it will do entire flow to register your application into Kyma, create CSR request and download the certificates to be used by your application.

In order to connect your application you need to generate your signingRequest URL:

* Kyma Opensource

If using Kyma Opensource installed over your local kubernetes, over one cloud provider kubernetes implementation or over gardener, you need to go to your kyma instance -> Application System, create your application and copy the signing request url.

* Kyma Managed Runtime

If using the Kyma Runtime available as a managed service on SAP Business Technology Platform, to create your application you need to go to SAP Business Technology Platform -> Global account -> System Landscape, create your System and Formation and copy the signing request url provided.

Once you have your signing request url, run the following command to connect your application to the just created kyma application:

registration = await kymaConnector.registerApp("<signingRequestUrl>");

The response of the registerApp command will be a json containing all the information and certificates to be used, please save this response in a safe location, it will be used everytime you need to connect to your kyma application.

connectKyma

Once your application is registered, everytime you want to use your kyma application, you must connect to it. The kyma-client-connector connectKyma command will load into your library your certificates and metadata, making the library aware of which application you want to be using. The input parameter of the connectkyma command is the json object returned by the registerApp command.

await  kymaConnector.connect(JSON.parse(registration));

registerService

The registerService command is used to register your application Events and API's into kyma, it is a JSON format which will describe the services you are registering, including authentication for the API's. For more information about the Registration JSON format, please visit https://kyma-project.io/docs/components/application-connector/#tutorials-register-a-service

The kyma-client-connector will take care of signing your api calls using the certificates generated in the registerApp process and it knows the urls to be called, based on the metadata provided. The only information that needs to be provided is the json object containing your services description.

Below an example of how to call the registerService method.

jsonBody = {
	"name": "Api and Event Test",
	"provider": "example-provider",
	"Identifier": "identifier",
	"description": "This is the long description of your service",
	"events": {
		"spec": {
			"asyncapi": "2.0.0",
			"info": {
				"title": "PetStore Events",
				"version": "2.0.0",
				"description": "Description of all the events"
			},
			"channels": {
				"stage.com.some.company.system/petCreated/v1": {
					"subscribe": {
						"message": {
							"summary": "Event containing information about new pet added to the Pet Store.",
							"payload": {
								"type": "object",
								"properties": {
									"pet": {
										"type": "object",
										"required": [
											"id",
											"name"
										],
										"example": {
											"id": "4caad296-e0c5-491e-98ac-0ed118f9474e",
											"category": "mammal",
											"name": "doggie"
										},
										"properties": {
											"id": {
												"title": "Id",
												"description": "Resource identifier",
												"type": "string"
											},
											"name": {
												"title": "Name",
												"description": "Pet name",
												"type": "string"
											},
											"category": {
												"title": "Category",
												"description": "Animal category",
												"type": "string"
											}
										}
									}
								}
							}
						}
					}
				}
			}
		}
	},
	"api": {
		"targetUrl": "https://httpbin.org/",
		"spec": {},
		"requestParameters": {
			"queryParameters": {
				"param": ["bar"]
			},
			"headers": {
				"custom-header": ["foo"]
			}
		},
		"credentials": {
			"basic": {
				"username": "{USERNAME}",
				"password": "{PASSWORD}"
			}
		}
	},
	"documentation": {
		"displayName": "Documentation",
		"description": "Description",
		"type": "some type",
		"tags": ["tag1", "tag2"],
		"docs": [{
			"title": "Documentation title...",
			"type": "type",
			"source": "source"
		}]
	}
}
	
serviceId = await kymaConnector.registerService(jsonBody);

updateService

The updateService command is used to update an already existing service into Kyma, the command is similar to the registerService, the only difference is that the serviceId of the existing service must be provided.

await  kymaConnector.updateService("<serviceId>", jsonBody);

deleteService

The deleteService command is used to delete an already existing service in Kyma for an application, only the serviceId must be provided.

await  kymaConnector.deleteService("<serviceId>");

getService

The getService command is used to retrieve the details of an existing service in Kyma for an application.

jsonBody = await kymaConnector.getService("<serviceId>");

sendEvent

If your application has events registered into Kyma, you can use the sendEvent command to push data into kyma, which can trigger a lambdaFunction or service. To send event to Kyma you only need to call the sendEvent with your data in json format as the parameter.

jsonBody = {
	"event-type":  "stage.com.some.company.system.petCreated",
	"event-type-version":  "v1",
	"event-time":  "2020-01-19T15:00:00Z",
	"data": {
		"category":  "mammal",
		"id":  "4caad296-e0c5-491e-98ac-0ed118f9474e",
		"name":  "doggie"
	}
}
return  await  kymaConnector.sendEvent(jsonBody);