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

@evodev/neko.db-socket

v1.0.1

Published

A package that make online database with socket.io

Downloads

13

Readme

Neko.DB-Socket

Is an online database socket package that is very easy to setup and connect.


Usage

Client Class

  • Client(config)

To make a new client with a config.

  • Client#connect()

To connect to the server with current setting.

  • Client#get(key, callback)

To get key's value and then call callback with key's value as argument. If callback is not a function, the code will return the value. This will throw an error if the client haven't connect to the server.

  • Client#on(event, callback)

To add a callback to an event. This will return an id of the callback.

  • Client#once(event, callback)

This is same with Client#on but the callback can only be used once.

  • Client#off(id)

To remove a callback by id.

  • Client#register()

To register the account to the server. This will not throw an error if the account is exist.

  • Client#set(key, value, callback)

To set key's value into value. If callback is a function, the code will call calback with key's new value as argument. If callback is not a function, the code will return the new value. This will throw an error if the client haven't connect to the server.


Server Class


  • Server(httpApp/port, config)

To make new socket server. (The arguments are same with socket.io's class).

  • Server#on(event, callback)

To add a callback to an event. This will return an id of the callback.

  • Server#once(event, callback)

This is same with Server#on but the callback can only be used once.

  • Server#off(id)

To remove a callback by id.


Example

Client Example


let { Client } = require("../index.js");
let client     = new Client({
  url    : "http://localhost:3000",
  account: {
    username: "Admin23",
    password: "admin123"
  }
});

client.on("connected", async () => {
  console.log(`Connected as ${client.connection.account.username}.`);
  let count = await client.get("count");
  switch(count) {
	case undefined:
	  count = 1;
	  await client.set("count", count);
	  break;
	default:
	  count+=1;
	  await client.set("count", count);
	  break;
  }
  console.log(count);
  client.on("disconnected", () => {
    console.log(`Disconnected.`);
  });
});

let connect = () => {
  client.connect();
};

client.on("registered", connect);
client.on("alreadyRegistered", connect);

setTimeout(function() {
  client.register();
}, 1000);

Server Example


let { Server } = require("../index.js");
let http       = require("http").createServer();
let server     = new Server(http);

http.listen(3000, () => {
  console.log("Listening at localhost:3000");
});

server.on("connection", (data) => {
  console.log(`A user is connected to the server.`);
});

server.on("register", (data) => {
  console.log(`A user is registered it's account.`);
});

server.on("registering", data => {
  return { status: false, reason: "You dumb" };
});

server.on("connecting", data => {
  return { status: false, reason: "You dumb" };
});

Note

You can get all Client#on and Server#on events in test/note.txt.


Donation

PayPal: nekomaru76


Support

Discord Server


Developer

Gaia#7541 (Discord)


Copyright (c) EvoDev Team, Inc - All Rights Reserved

  • This work is licensed under the Recex Shared Source License Version 1.0.
  • To view a copy of this license, visit the site.
  • Written by Gaia [email protected], October 2020.