New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@flytio/int-sdk

Package Overview
Dependencies
Maintainers
1
Versions
56
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@flytio/int-sdk

Standard library used for various integrations

  • 0.9.1
  • unpublished
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
0
Maintainers
1
Weekly downloads
 
Created
Source

npm version

INT SDK

A standard library for integrations in Flyt. The library aims to help to speed up future integrations by extracting common parts. This way in case of any update you don't have to update the code, but only the version of the library. See original proposal.

How does it work?

The library sets up some things for you.

1. HTTP server

It runs an express server on port 8080 to expose metrics and liveness probe.

/metrics
/healthz

2. GRPC server

It creates a GRPC server and assigns your implementation to its services.

3. Prometheus

It registers Prometheus metrics and places some counters and histograms (using prom-client package) into the integration calls.

4. Axios

It exports HttpClientFactory that sets interceptors with a logger, and metrics and configures default timeout.

5. Handy wrappers

It also exports wrappers for Menu and Ordering services that simplify passing logger and httpInsntace down to the integration so you don't have to think about extracting requestId from metadata.

Example

You have to create a LoggerFactory instance that is shared between the integration factory and your implementation. This way you can keep the logs under the same app name. Also you may want to create an httpClient instance using LoggerFactory insntace to make use of metrics and logs already set up using interceptors.

import {
  IntegrationFactory,
  LoggerFactory,
  HttpClientFactory,
  OrderingServiceWrapper,
  OrderingService,
} from '@flytio/int-sdk';
import { MyOrderingImplementation, APP_NAME } from './src/my-class';

// 1. create a logger factory instance
const loggerFactory = new LoggerFactory(APP_NAME);
// 2. use logger factory instance to create http client factory instance
const httpClientFactory = new HttpClientFactory(loggerFactory);
// 3. MyOrderingImplementation implements
// OrderingService exported from @flytio/int-sdk
const myOrdering = new MyOrderingImplementation();

// 4. OrderingServiceWrapper implements
// OrderingGrpcService exported from @flytio/protos
const ordering = new OrderingServiceWrapper(
  myOrdering,
  loggerFactory,
  httpClientFactory,
);

// 5. create an integration
const integration = new IntegrationFactory({
  loggerFactory,
  appName: APP_NAME,
  ordering,
});

// 6. and make grpc server and http server listen
integration.run();

Development

Code style

We use prettier to format code before commit (using husky hooks).

Our config.

Testing

For testing we use Jest. Unit tests are placed inside __tests__ directory. Integration tests are placed in __integration-tests__ directory.

Deployment

The library is distributed as an npm package and publishing happens automatically through CircleCI after merging to master.

Versioning

We follow semantic versioning approach. To ensure you bump the version number there is a script to run before you push.

FAQs

Package last updated on 15 Feb 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc