npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

virtualizorjs

v1.0.5

Published

VirtualizorJS simplifies the management of Virtualizor servers with a streamlined and developer-friendly API for Node.js. Perform actions such as creating, starting, stopping, and restarting virtual servers effortlessly. Ideal for seamless integration int

Downloads

39

Readme

VirtualizorJS

Since there is no SDK's for Node.js for the Virtualizor API, I decided to create one, and one that is actually easy to use and useful with 0 Dependencies keeping it Lightweight and Fast.

VirtualizorJS simplifies the management of Virtualizor servers with a streamlined and developer-friendly API for Node.js. Perform actions such as creating, starting, stopping, and restarting virtual servers effortlessly. Ideal for seamless integration into your Node.js applications, providing a powerful toolkit for Virtualizor server management.

GitHub stars

Npm package version Maintenance

Important

  • This library is still in development and there is more to add but for now it's stable and ready to use, all the methods have been tested and work as expected.

Table of Contents

Installation

npm i virtualizorjs@latest

Usage


const VirtualizorClient = require('virtualizorjs');

// Initialize VirtualizorClient
const { ListVPS } = new VirtualizorClient({
  host: '< IP or Hostname of Virtualizor Server >',
  port: 4085, // or 4085 for SSL
  adminapikey: "< Your API KEY >",
  adminapipass: "< Your API PASS >",
});

// Using const client = new VirtualizorClient({ ... }) is also valid, but you will have to use client.ListVPS() instead of ListVPS() which just looks ugly.
// Example: Get a list of all VPSs
ListVPS().then((data) => {
  console.log(data);
}).catch((err) => {
  console.log(err);
});

Event Handling Usage

VirtualizorJS uses the EventEmitter class to handle events. You can attach Event Listeners to different events provided by the VirtualizorClient.

  • Note: To use Event Listeners we need to define the VirtualizorClient as a const named preferably Client and then use Client.on() to attach Event Listeners to different events.
const VirtualizorClient = require('virtualizorjs'); 

const Client = new VirtualizorClient({
  host: '< IP or Hostname of Virtualizor Server >',
  port: 4085,
  adminapikey: "< Your API KEY >",
  adminapipass: "< Your API PASS >",
});

//Get the methods you need
const { StartVPS } = Client;

// - Event Types - :
// 1. vpsCreated
// 2. vpsStarted
// 3. vpsStopped
// 4. vpsRestarted

// Event listener for when a virtual server is created
Client.on('vpsCreated', (response) => {
  console.log(`Virtual Server Created! Details:`, response);
});

// Event listener for when a virtual server is started
Client.on('vpsStarted', (response) => {
  console.log(`Virtual Server Started! Details:`, response);
});

// Event listener for when a virtual server is stopped
Client.on('vpsStopped', (response) => {
  console.log(`Virtual Server Stopped! Details:`, response);
});

// Event listener for when a virtual server is restarted
Client.on('vpsRestarted', (response) => {
  console.log(`Virtual Server Restarted! Details:`, response);
});

❓ What's the point of using Event Listeners?

  • Event Listeners are useful when you want to perform an action when a certain event occurs without modifying the source code of the VirtualizorJS library to avoid breaking changes.
  • For example, you can use Event Listeners to send a notification to your users when a event is triggered.
  • You can also use Event Listeners to perform an action when a event is triggered.

Examples

Documentation

  • Check the Wiki for detailed documentation.
  • If you use frameworks such as Next.js make sure to use it only Server-Side for security reasons.

Roadmap

  • [ ] Add Proxmox KVM Support
  • [ ] Add Virtualization Types enums

Contributing

  • Feel free to contribute by opening issues or submitting pull requests. See CONTRIBUTING for details.

License

  • This project is licensed under the MIT License - see the LICENSE file for details.