Node.JS

Confly Node.JS integration

https://github.com/confly-dev/confly-js (opens in a new tab)

Features

  • Fetch your instance data from Confly
  • Auto use an env variable for the instance token or pass it as a parameter
  • Comin soon: Full Type safety

Installation

npm install @confly-dev/confly-js

Usage

const { getConfig } = require("@confly-dev/confly-js");
 
// Using the env variable 'CONFLY_INSTANCE'
const confly = await getConfig();
 
// Passing the token as a parameter
const confly = await getConfig("my-token");
 
// Without top level await
getConfig().then((confly) => {
  // Do something with confly
});

Example

Here's a simple example of how to use the package to send a request to an endpoint using the config from Confly.

const { getConfig } = require("@confly-dev/confly-js");
const fetch = require("node-fetch");
 
getConfig().then((confly) => {
  fetch(confly.endpoint, {
    headers: confly.headers,
    method: confly.method,
    body: JSON.stringify(confly.body),
  })
    .then((res) => res.json())
    .then((json) => console.log(json));
});

Support

For support, visit our Discord (opens in a new tab) or open an issue on GitHub.