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

api-integrations-backend

v1.0.0

Published

This repository contains the backend API which is responsible for managing access tokens, checking the heartbeats of deployments, and performing other operational tasks. The system manages tokens two type of tokens: Grafana Loki access tokens and signed A

Downloads

3

Readme

API integrations backend

This repository contains the backend API which is responsible for managing access tokens, checking the heartbeats of deployments, and performing other operational tasks. The system manages tokens two type of tokens: Grafana Loki access tokens and signed API access tokens. The former facilitates the authorization process for partner providers, empowering them to send airnode-feed logs. Meanwhile, the latter type of tokens is used to authorize partner providers to send signed data to signed-api deployed by Nodary and API3. Beyond token management, the system intelligently processes the heartbeat logs from 'airnode-feed' deployments, offering a comprehensive mechanism to assess the status of these deployments.

Getting started

Configuration

  1. Copy .env from the example.env file.
  2. Open the .env file and update the environment variables:
    • HTTP_API_ID: ID of the AWS HTTP API Gateway
    • API_KEY_LIST: List of API keys that are allowed to use the API in the format user1:key1,user2:key2
    • GF_CLOUD_REGION: Region of the utilizied Grafana Cloud instance
    • GF_CLOUD_TOKEN: Grafana Cloud token that is enabled to generate token and read logs
    • GF_CLOUD_ACCESS_POLICY_ID: Policy to be used while generating token, expected to be authorized to write logs only
    • GF_LOKI_USER: Grafana Loki user able to use endpoint GF_LOKI_ENDPOINT
    • GF_LOKI_ENDPOINT: Grafana Loki HTTP API endpoint

Deployment

To deploy infrastructure to AWS:

pnpm run serverless:deploy --region us-east-2 --stage prod

To remove deployment:

pnpm run serverless:remove --region us-east-2 --stage prod

Public endpoint

This service is publicly accessible at the following endpoint:

Usage

The API provides the following endpoints:

  • POST /grafanaLokiAccess: Generate token that will be used to authorize partner providers to send Airnode feed logs
  • GET /grafanaLokiAccess: Get Grafana Loki access token for the given Airnode address
  • DELETE /grafanaLokiAccess: Delete Grafana Loki access token
  • POST /signedApiAccess: Generate token that will be used to authorize partner providers to send signed data
  • GET /signedApiAccess: Get signed API access token for the given Airnode address
  • DELETE /signedApiAccess: Delete signed API access token
  • GET /deploymentStatus: Get status for the deployment

Local development

Start local dynamodb server:

pnpm run local:db:up

Initialize tables:

pnpm run local:db:init

Spin up local express server to mimic AWS API gateway:

pnpm run local:start

You can use following valid examples in the next section to test server.

Examples

  • Generate Grafana Loki access token:

# POST_/grafanaLokiAccess
curl --location --request POST 'https://api-integrations.nodary.io/grafanaLokiAccess?airnode=0x27f093777962Bb743E6cAC44cd724B84B7254aad' \
--header 'x-api-key: user1:pass1'

# Response will be:
# {
#    "airnode": "0x27f093777962Bb743E6cAC44cd724B84B7254aad",
#    "generatedBy": "user1",
#    "lokiEndpoint": "logs-prod-012.grafana.net",
#    "lokiToken": "EXAMPLE_eyJIjoW5nV2FzVl_TOKEN"
#    "lokiTokenId": "EXAMPLE-ca5a-TOKEN-bfd0-ID",
#    "lokiUser": "34567"
# }
# or
# {
#   "message": "Grafana Loki access record for 0x27f093777962Bb743E6cAC44cd724B84B7254aad already exists"
# }

# GET_/grafanaLokiAccess
curl --location 'https://api-integrations.nodary.io/grafanaLokiAccess?airnode=0x27f093777962Bb743E6cAC44cd724B84B7254aad' \
--header 'x-api-key: user1:pass1'

# Response will be:
# {
#    "airnode": "0x27f093777962Bb743E6cAC44cd724B84B7254aad",
#    "generatedBy": "user1",
#    "lokiEndpoint": "logs-prod-012.grafana.net",
#    "lokiToken": "EXAMPLE_eyJIjoW5nV2FzVl_TOKEN"
#    "lokiTokenId": "EXAMPLE-ca5a-TOKEN-bfd0-ID",
#    "lokiUser": "34567"
# }
# or
# {
#   "message": "No Grafana Loki access record found for 0x27f093777962Bb743E6cAC44cd724B84B7254aad"
# }

# DELETE_/grafanaLokiAccess
curl --location --request DELETE 'https://api-integrations.nodary.io/grafanaLokiAccess?airnode=0x27f093777962Bb743E6cAC44cd724B84B7254aad' \
--header 'x-api-key: user1:pass1'

# Response will be:
# {
#   "message": "Grafana Loki access record for 0x27f093777962Bb743E6cAC44cd724B84B7254aad has been deleted"
# }
# or
# {
#   "message": "No Grafana Loki access record for 0x27f093777962Bb743E6cAC44cd724B84B7254aad found to delete"
# }

# POST_/signedApiAccess
curl --location --request POST 'https://api-integrations.nodary.io/signedApiAccess?airnode=0x27f093777962Bb743E6cAC44cd724B84B7254aad' \
--header 'x-api-key: user1:pass1'

# Response will be:
# {
#   "airnode": "0x27f093777962Bb743E6cAC44cd724B84B7254aad",
#   "bearerToken": {
#       "api3": {
#           "airnodeFeed": "EXAMPLETOKEN926461c16ce994846f9decc827f42e",
#           "oev": "926461c16ce994846f9decc827f42eEXAMPLETOKEN"
#       },
#       "nodary": {
#           "airnodeFeed": "926461c16ce994846f9decc827fEXAMPLETOKEN42e",
#           "oev": "926461c16cEXAMPLETOKENe994846f9decc827f42e"
#       }
#   },
#   "generatedBy": "user1"
# }
# or
# {
#   "message": "Signed API access record for 0x27f093777962Bb743E6cAC44cd724B84B7254aad already exists"
# }

# GET_/signedApiAccess
curl --location 'https://api-integrations.nodary.io/signedApiAccess?airnode=0x27f093777962Bb743E6cAC44cd724B84B7254aad' \
--header 'x-api-key: user1:pass1'

# Response will be:
# {
#   "airnode": "0x27f093777962Bb743E6cAC44cd724B84B7254aad",
#   "bearerToken": {
#       "api3": {
#           "airnodeFeed": "EXAMPLETOKEN926461c16ce994846f9decc827f42e",
#           "oev": "926461c16ce994846f9decc827f42eEXAMPLETOKEN"
#       },
#       "nodary": {
#           "airnodeFeed": "926461c16ce994846f9decc827fEXAMPLETOKEN42e",
#           "oev": "926461c16cEXAMPLETOKENe994846f9decc827f42e"
#       }
#   },
#   "generatedBy": "user1"
# }
# or
# {
#   "message": "No signed API access record found for 0x27f093777962Bb743E6cAC44cd724B84B7254aad"
# }

# DELETE_/signedApiAccess
curl --location --request DELETE 'https://api-integrations.nodary.io/signedApiAccess?airnode=0x27f093777962Bb743E6cAC44cd724B84B7254aad' \
--header 'x-api-key: user1:pass1'

# Response will be:
# {
#     "message": "Signed API access record for 0x27f093777962Bb743E6cAC44cd724B84B7254aad has been deleted"
# }
# or
# {
#   "message": "No signed API access record for 0x27f093777962Bb743E6cAC44cd724B84B7254aad found to delete"
# }
  • Check deployment status for the airnode-feed with airnode address 0x6CFec029322bfb6f8f6a5A6662b4A3136eeD83A7
# GET_/deploymentStatus
curl --location 'https://api-integrations.nodary.io/deploymentStatus?airnode=0x27f093777962Bb743E6cAC44cd724B84B7254aad&app=airnode-feed'

References

  • Custom domain support for AWS API Gateway and CDN caching, see the page.