Skip to content

http.Agent implementation to connect to Codezero Teamspaces

License

Notifications You must be signed in to change notification settings

c6o/codezero-agent-nodejs

Repository files navigation

Codezero http.Agent implementation for NodeJS

Example using node-fetch

import fetch from "node-fetch";
import { CodezeroAgent } from "@c6o/codezero-agent";

const agent = new CodezeroAgent();
const response = await fetch("http://my-service.namespace/path", { agent });

Example using Axios

import axios from "axios";
import { CodezeroAgent } from '@c6o/codezero-agent';

const agent = new CodezeroAgent();
const response = axios({
    method: 'get',
    url: 'http://my-service.namespace/path',
    httpAgent: agent,
});

Example using http.request

import * as http from "http";
import { CodezeroAgent } from "@c6o/codezero-agent";

const agent = new CodezeroAgent();

http.get("http://my-service.namespace/path", { agent }, (res) => {
  console.log(res.statusCode, res.headers);
  res.pipe(process.stdout);
});

API

new CodezeroAgent({ orgID: string, orgAPIKey: string, spaceID: string })

Returns implementation of an http.Agent that connects to the Teamspace with the given spaceID.

You can get the orgID and orgAPIKey in the Codezero Hub.

Alternatively to passing constructor arguments, you can set the following environment variables:

Environment Variable Description
CZ_ORG_ID Codezero Organization ID
CZ_ORG_API_KEY Codezero API Key of your Organization
CZ_SPACE_ID Codezero Space ID

About

http.Agent implementation to connect to Codezero Teamspaces

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 3

  •  
  •  
  •