← Back 300 APIs integrated in minutes, not days u11g.com
1/30/2023

300 APIs integrated in minutes, not days

#typescript#nodejs#beginners#tutorial#webdev#api
const config = nao<Auth0.CreateUser>({ 
  kind: "auth0.users.create", 
  "auth:Authorization": "token", 
  "subdomain:tenant": "tenant", 
  "body:email": "email", 
  "body:family_name": "last", 
  "body:given_name": "first", 
});

The config object contains everything you need to fire the request against the API endpoint: method, url, headers, body. Now you can use your favorite http client to execute the real call (mine is fetch since it’s available in both envs: browser and server).

The flethy connectors package is fully typed: you don’t need to know how the payload is structured, what the URL for the specific use case is and which method has to be used. Get started with flethy by just installing the package and then, yeah, select your favorite service to integrate!

npm i @flethy/connectors 
# or 
yarn add @flethy/connectors 
# or 
pnpm add @flethy/connectors

Try it out with webhook.site:

import { nao, WebhookSite } from "@flethy/connectors"; 
const config = nao<WebhookSite.CoreGet>({ 
  kind: "webhooksite.core.get", 
  "param:uuid": "your-individual-uuid", 
  "header:x-test-header": "flethy", 
}); 
console.log(config);

For me, that was not all. As a rule, it doesn’t stay with just one step. I usually have several steps that have to be executed partly sequentially and partly in parallel. So why not merge the configurations together into one flow? Let’s take the Auth0 Management API. I first need to get an access token to then interact with the API. What if it could then look like this?

[ 
  { 
    "id": "token", 
    "config": { "namespace": "token" }, 
    "next": [ { "id": "createUser" } ], 
    "kind": "auth0.auth.accesstoken", 
    "body:audience": "==>env==>AUTH0_AUDIENCE", 
    "body:grant_type": "client_credentials", 
    "body:client_id": "==>secrets==>AUTH0_CLIENT_ID", 
    "body:client_secret": "==>secrets==>AUTH0_CLIENT_SECRET", 
    "subdomain:tenant": "==>env==>AUTH0_TENANT" 
  }, 
  { 
    "id": "createUser", 
    "config": { "namespace": "createUser" }, 
    "kind": "auth0.users.create", 
    "auth:Authorization": "->context.token.access_token->string", 
    "subdomain:tenant": "==>env==>AUTH0_TENANT", 
    "body:email": "->context.input.email->string", 
    "body:family_name": "->context.input.last->string", 
    "body:given_name": "->context.input.first->string" 
  } 
]

Two steps are executed one after the other, the result from the first step is used in the second step. And as you can see, the description is a simple JSON. That means I’m programming language agnostic (what a word). Wohoo! So now how about just deploying this description to the cloud, and it will be executed there, and you don’t have to worry about it yourself. And that’s exactly what I’m working on right now. A first version is ready, a little fine-tuning is missing and then we can start.

The nice thing for me about this approach is that I can try everything out locally without any further dependencies before I deploy it to the cloud. I’m looking forward to your feedback! And if you want to stay up to date, sign up at flethy.com and get regular news! And write to me if you are missing an integration!