From aacdaf4556053c74f9d4a750716eb974d7ef54dc Mon Sep 17 00:00:00 2001 From: Tuan Dang Date: Sun, 23 Apr 2023 12:45:13 +0300 Subject: [PATCH] Modify Node SDK docs to be inline with new initializer --- docs/sdks/languages/node.mdx | 57 +++++++----------------------------- 1 file changed, 10 insertions(+), 47 deletions(-) diff --git a/docs/sdks/languages/node.mdx b/docs/sdks/languages/node.mdx index 28ce8cf00..5a51afc79 100644 --- a/docs/sdks/languages/node.mdx +++ b/docs/sdks/languages/node.mdx @@ -14,20 +14,15 @@ npm install infisical-node --save ## Configuration -Import the SDK and call `connect()` with your Infisical token as early as possible in the main entry module of your application. This initializes the global instance of the SDK, which can be accessed anywhere in your application. - -For multiple Infisical projects or creating multiple SDK instances, use `createConnection()` instead. This returns a local SDK instance, independent of the global instance. - -### infisical.connect(options) - +Import the SDK and create a client instance with your Infisical token. ```js - import infisical from "infisical-node"; - - infisical.connect({ - token: "your_infisical_token", + import InfisicalClient from "infisical-node"; + + const client = new InfisicalClient({ + token: "your_infisical_token" }); // your app logic @@ -36,9 +31,9 @@ For multiple Infisical projects or creating multiple SDK instances, use `createC ```js - const infisical = require("infisical-node"); + const InfisicalClient = require("infisical-node"); - infisical.connect({ + const client = new InfisicalClient({ token: "your_infisical_token" }); @@ -48,8 +43,6 @@ For multiple Infisical projects or creating multiple SDK instances, use `createC -Updates the global instance of the Infisical client with a connection to an Infisical project with the [Infisical Token](/getting-started/dashboard/token). - @@ -73,36 +66,6 @@ Updates the global instance of the Infisical client with a connection to an Infi -### infisical.createConnection(options) - -Returns a local instance of the Infisical client with a connection to an Infisical project with an [Infisical Token](/getting-started/dashboard/token). - -This method is useful if you wish to connect to two or more Infisical projects within your app. - - - - - An [Infisical Token](/getting-started/dashboard/token) scoped to a project - and environment - - - Your self-hosted absolute site URL including the protocol (e.g. - `https://app.infisical.com`) - - - Time-to-live (in seconds) for cached secrets. If set to 0, data is cached indefinitely. - - - Whether or not debug mode is on - - - - - ## Usage ### infisical.getSecret(secretName, options) @@ -194,18 +157,18 @@ Delete a secret in Infisical. ## Example with Express ```js -import infisical from "infisical-node"; +import InfisicalClient from "infisical-node"; import express from "express"; const app = express(); const PORT = 3000; -infisical.connect({ +const client = new InfisicalClient({ token: "YOUR_INFISICAL_TOKEN" }); app.get("/", async (req, res) => { // access value - const name = await infisical.getSecret("NAME"); + const name = await client.getSecret("NAME"); res.send(`Hello! My name is: ${name.secretValue}`); });