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

wg-easy-peazy

v1.0.38

Published

Convenient TypeScript compatible library for interacting with the wg-easy API

Downloads

16

Readme

wg-easy-peazy

Convenient TypeScript compatible library for interacting with the wg-easy API

Installation

Install it from npm:

npm/yarn/bun install wg-easy-peazy

Error Handling

When a request encounters an error, the response will contain an object with the variable "error" This object will provide relevant information about the error Example: { error: 'The name wg-easy is already taken' }

Usage

Create a new instance of the WGEasyWrapper class

import WGEasyWrapper from 'wg-easy-peazy';
// const WGEasyWrapper = require('wg-easy-peazy'); // for node

const wgEasy = new WGEasyWrapper('https://website.com:51820', 'password_example');

Getting the release version

await wgEasy.getRelease();
// 

Getting a session

await wgEasy.getSession();
// { requiresPassword: true, authenticated: true }

Creating a wg-easy client

await wgEasy.create('newClient');
/*{
  id: '721f6ac2-ab4f-2fz2-v1b4-2gtc93462099',
  name: 'newClient',
  enabled: true,
  address: '10.8.0.1',
  publicKey: 'a2DdjFEO6fcs4fBGbyNlcaczF2trFkCpjFELcc71Cz0=',
  createdAt: '2023-07-18T00:00:00.000Z',
  updatedAt: '2023-07-18T00:00:00.000Z',
  persistentKeepalive: 'off',
  latestHandshakeAt: null,
  transferRx: 0,
  transferTx: 0
}*/

Deleting a wg-easy client

await wgEasy.delete('721f6ac2-ab4f-2fz2-v1b4-2gtc93462099');
// { message: 'Deleted' }

Getting wg-easy clients

await wgEasy.getClients();
/*[
  {
    id: 'f2t3bdbh-b340-4e7d-62f7-651a0122bc62',
    name: 'testName',
    enabled: true,
    address: '10.8.0.0',
    publicKey: 'qd2BCXsnsw/USjV92emeexTL5S87mJwU7J85MyjgqW4=',
    createdAt: '2023-07-18T00:00:00.000Z',
    updatedAt: '2023-07-18T00:00:00.000Z',
    persistentKeepalive: 'off',
    latestHandshakeAt: null,
    transferRx: 0,
    transferTx: 0
  },
  {
     ...
  }
]*/

Getting wg-easy client configuration

await wgEasy.getConfig('f2t3bdbh-b340-4e7d-62f7-651a0122bc62');
/*
[Interface]
PrivateKey = ...
Address = 10.8.0.0/24
DNS = 1.1.1.1


[Peer]
PublicKey = ...
PresharedKey = ...
AllowedIPs = 0.0.0.0/0, ::/0
PersistentKeepalive = 0
Endpoint = website.com:51820
*/

Getting wg-easy client qr-code

await wgEasy.getQRCode('f2t3bdbh-b340-4e7d-62f7-651a0122bc62');
/*
<svg xmlns="http://www.w3.org/2000/svg" width="512" height="512" viewBox="0 0 77 77" shape-rendering="crispEdges">
    <path fill="#ffffff" d="M0 0h77v77H0z"/>
    <path stroke="#000000" d="M4 ... 0h2m2 0h1"/>
</svg>
*/

Enable wg-easy client

await wgEasy.enable('f2t3bdbh-b340-4e7d-62f7-651a0122bc62');
// { message: 'Enabled' }

Disable wg-easy client

await wgEasy.disable('f2t3bdbh-b340-4e7d-62f7-651a0122bc62');
// // { message: 'Disabled' }

Rename wg-easy client

await wgEasy.rename('f2t3bdbh-b340-4e7d-62f7-651a0122bc62', 'newName');
// { message: 'Renamed' }

Update wg-easy client address

await wgEasy.updateAddress('f2t3bdbh-b340-4e7d-62f7-651a0122bc62', '10.8.0.1');
// { message: 'Address updated' }

Find wg-easy client

await wgEasy.find('newName'); // or id or addres
/*{
  id: 'f2t3bdbh-b340-4e7d-62f7-651a0122bc62',
  name: 'newName',
  enabled: true,
  address: '10.8.0.0',
  publicKey: 'qd2BCXsnsw/USjV92emeexTL5S87mJwU7J85MyjgqW4=',
  createdAt: '2023-07-18T00:00:00.000Z',
  updatedAt: '2023-07-18T00:00:00.000Z',
  persistentKeepalive: 'off',
  latestHandshakeAt: null,
  transferRx: 0,
  transferTx: 0
}*/

License

This project is licensed under the MIT License. You are free to modify and distribute the code as per the terms of the license.