Socket
Socket
Sign inDemoInstall

vndb

Package Overview
Dependencies
2
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    vndb

VNDB API wrapper


Version published
Weekly downloads
30
increased by328.57%
Maintainers
1
Created
Weekly downloads
 

Readme

Source

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 = require('vndb');

(async () => {
  try {
    const vndb = await VNDB.start();
    console.log('Connected!');
  } catch (e) {
    console.log('Something happened when connecting to VNDB API');
  }
})();

You can pass in host/port optionally. This is not required 99% of the times, unless VNDB changes host/port.

const vndb = await VNDB.start('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 VNDB.start();
const res0 = await vndb.write('login {"protocol":1,"client":"VNDB-Reborn-Tester","clientver":"0.0.1"}');
const res1 = await vndb.write('dbstats');
const res2 = await vndb.write('get vn basic,anime (id = 17)');
  • vndb.end()

End the socket connection. Can be await-ed if you want to make sure that it really ends.

const vndb = await VNDB.start();
const res0 = await vndb.write('login {"protocol":1,"client":"VNDB-Reborn-Tester","clientver":"0.0.1"}');
await vndb.end();
  • 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

Keywords

FAQs

Last updated on 01 Apr 2017

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc