@nerdvision/agent
TypeScript icon, indicating that this package has built-in type declarations

2.0.4 • Public • Published

https://nerd.vision node agent

This is the official nerd.vision node agent. We're constantly looking to improve, so please send us feedback on it's usability and if you find any issues! You can see the known issues at the bottom of this readme.

Requirements

  • Node 10+

Documentation

You can find the documentation at docs.nerd.vision

Installation

npm i @nerdvision/agent

Configuration Properties

All configuration properties are defined in NerdVisionConfig

interface NerdVisionConfig {
	api_key: string;
	name?: string; // default: my-node-app
	debug?: boolean; // default: false
	tags?: { [key: string]: string }; // default: {}
}
Breaking change in v1.0.0: ️apiKey has been renamed to api_key

Usage

Both init and wrap accept an API key, or the configuration object. The example below is typescript, but nerd.vision works perfectly with normal javascript as well.

const {nerdvision, NerdVisionConfig} = require('@nerdvision/agent');

const config: NerdVisionConfig = {
	api_key: 'API_KEY', // you can find yours at https://account.nerd.vision/account/apikeys
};

//
// THEN
//

nerdvision.init('API_KEY').then(() => {
	// application code
});

//
// OR
//

nerdvision.init(config).then(() => {
	// application code
});

When Node exits, nerd.vision should automatically disconnect. If you want to ensure that it has disconnected, you can explicitly call close in your shutdown handler:

nerdvision.close();

You can also use .wrap to automatically disconnect after your code has run. This is more useful for applications that shut down after processing.

nerdvision.wrap(config, async () => {
	// application code
	
	// this function must return a promise
	// when it resolves, nerd.vision will disconnect automatically
});

Examples

There are two example node applications for nerd.vision.

Troubleshooting

I get the error TS7016: Could not find a declaration file for module 'google-protobuf'

  • You need to install types for google-protobuf: npm i -D @types/google-protobuf

I get errors when i use import on nerd.vision

  • Please use the require syntax above for now, we're actively looking into fixing this

Known issues

  • When using a pre-processor for JavaScript, like TypeScript, files that are lazy loaded may not trigger until they are run for a second time.
  • ts-node is not supported yet. As a work around, you can build your code with tsc and run it directly with node for tracepoints to fire

Package Sidebar

Install

npm i @nerdvision/agent

Homepage

nerd.vision

Weekly Downloads

6

Version

2.0.4

License

See /LICENSE

Unpacked Size

310 kB

Total Files

90

Last publish

Collaborators

  • bedonath
  • intergral
  • bdonnell