Git Product home page Git Product logo

external-adapters-js's Introduction

Chainlink External Adapters (JavaScript)

This repository contains the source for Chainlink external adapters. Each adapter must document its own required parameters and output format.

Requirements

  • Yarn

Install

yarn

Installs packages for all workspaces.

Test

In order to test adapters locally, you may need to set an $API_KEY environment variable for the given API.

cd $adapter
yarn test

Creating a new external adapter

Run the command below to have the example directory cloned using the name you provide for $adapter:

make new adapter=my-adapter-name

If on a Mac, this requires gnu-sed to be installed and set as the default for the command sed.

Docker

To build a Docker container for a specific $adapter, use the following example:

make docker adapter=bravenewcoin

The naming convention for Docker containers will be $adapter-adapter.

Then run it with:

docker run -p 8080:8080 -e API_KEY='YOUR_API_KEY' -it bravenewcoin-adapter:latest

Serverless

Create the zip:

make zip adapter=bravenewcoin

The zip will be created as ./$adapter/dist/$adapter-adapter.zip.

Install to AWS Lambda

  • In Lambda Functions, create function
  • On the Create function page:
    • Give the function a name
    • Use Node.js 12.x for the runtime
    • Choose an existing role or create a new one
    • Click Create Function
  • Under Function code, select "Upload a .zip file" from the Code entry type drop-down
  • Click Upload and select the $adapter-adapter.zip file
  • Handler:
    • index.handler for REST API Gateways
    • index.handlerv2 for HTTP API Gateways
  • Add the environment variable (repeat for all environment variables):
    • Key: API_KEY
    • Value: Your_API_key
  • Save

By default, Lambda functions time out after 3 seconds. You may want to change that to 60s in case an API takes longer than expected to respond.

To Set Up an API Gateway (HTTP API)

If using a HTTP API Gateway, Lambda's built-in Test will fail, but you will be able to externally call the function successfully.

  • Click Add Trigger
  • Select API Gateway in Trigger configuration
  • Under API, click Create an API
  • Choose HTTP API
  • Select the security for the API
  • Click Add

To Set Up an API Gateway (REST API)

If using a REST API Gateway, you will need to disable the Lambda proxy integration for Lambda-based adapter to function.

  • Click Add Trigger
  • Select API Gateway in Trigger configuration
  • Under API, click Create an API
  • Choose REST API
  • Select the security for the API
  • Click Add
  • Click the API Gateway trigger
  • Click the name of the trigger (this is a link, a new window opens)
  • Click Integration Request
  • Uncheck Use Lamba Proxy integration
  • Click OK on the two dialogs
  • Return to your function
  • Remove the API Gateway and Save
  • Click Add Trigger and use the same API Gateway
  • Select the deployment stage and security
  • Click Add

Install to GCP

  • In Functions, create a new function, choose to ZIP upload
  • Select Node.js 10 for the Runtime
  • Click Browse and select the $adapter-adapter.zip file
  • Select a Storage Bucket to keep the zip in
  • Function to execute: gcpservice
  • Click More, Add variable (repeat for all environment variables)
    • NAME: API_KEY
    • VALUE: Your_API_key

external-adapters-js's People

Contributors

boxhock avatar henrynguyen5 avatar micdorn avatar rstormsf avatar se3000 avatar thodges-gh avatar tyrion70 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.