Skip to content

Repository files navigation

Codezero http.Agent implementation for NodeJS

Example using node-fetch

importfetchfrom"node-fetch";import{CodezeroAgent}from"@c6o/codezero-agent";constagent=newCodezeroAgent();constresponse=awaitfetch("http://my-service.namespace/path",{ agent });

Example using Axios

importaxiosfrom"axios";import{CodezeroAgent}from'@c6o/codezero-agent';constagent=newCodezeroAgent();constresponse=axios({method: 'get',url: 'http://my-service.namespace/path',httpAgent: agent,});

Example using http.request

import*ashttpfrom"http";import{CodezeroAgent}from"@c6o/codezero-agent";constagent=newCodezeroAgent();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 VariableDescription
CZ_ORG_IDCodezero Organization ID
CZ_ORG_API_KEYCodezero API Key of your Organization
CZ_SPACE_IDCodezero Space ID

About

http.Agent implementation to connect to Codezero Teamspaces

Resources

Security policy

Stars

0 stars

Watchers

2 watching

Forks

Releases

Used by

Contributors

Languages