@c6o/codezero-agent
v1.0.2
Published
Codezero http.Agent implementation for NodeJS
Readme
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 |
