VNDB Reborn
A simple node.js wrapper for VNDB API. Reference: https://vndb.org/d11.
Installation
$ npm install vndb
Usage
VNDB
exposes an object that contains only a single function .start([host], [port])
. This is an asynchronous function that tries to connect to VNDB API.
const VNDB = ; async { try const vndb = await VNDBstart; console; catch e console; };
You can pass in host/port optionally. This is not required 99% of the times, unless VNDB changes host/port.
const vndb = await VNDBstart'myvndb.com' 1234;
The start function itself returns an object that contains the socket and 2 convenient methods to interact with it.
vndb.write(message)
Write a raw message to VNDB API. Specification should follow https://vndb.org/d11. This function will add terminator and queue the message accordingly, as one socket can only send/receive one message at a time.
const vndb = await VNDBstart;const res0 = await vndb;const res1 = await vndb;const res2 = await vndb;
vndb.end()
End the socket connection. Can be await-ed if you want to make sure that it really ends.
const vndb = await VNDBstart;const res0 = await vndb;await vndb;
vndb.socket
The socket object, an instance of native tls.TLSSocket
.
Debugging
debug module is included and used for debugging purpose, under vndb
namespace.
DEBUG=vndb node index.js