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

chatserver

v0.0.1

Published

Chat server

Downloads

2

Readme

I wanted to create npm package which I could expand in the future and add server which can be listening by xmlrpc protocol. It has got two methods: get instance of creator server and set the listner by jsonrpc protocol. Now It works only by jsonrpc protocol.

I wanted to show the modular structure of the application where each module performs its functions.

  1. chatserver/lib/ChatServerConfig.js - It is module which doing configuration the application. It takes the configuration from administrator, checks it and if something wrong - sets the default values.

  2. chatserver/lib/ChatServerStorage.js - This module works with data. In our case here work with redis. The main thing I would like to draw attention - it is using publish/subscribe in redis. This allows you to scale the application.

  3. chatserver/lib/ChatServer.js - This module creates server instance by configuration, set listner and create builder of responses. When user connects he can send commands using jsonrpc protocol. The program parse messages, and call the command methods. For each connection the program creates storage instance where is created publisher and subscriber. Responses are sending to listner by callbacks where they are being sent to user using web socket. It is basic logic of this program.

I wanted to create flexible mechanism for configuration using yarg package. You can see how I have done it here - (chatserver/lib/constants/config.js) As the result you can give to the program some configuration file like this /path/to/node_chat/chatServer.js --config=configExample.json Run the program with option --help to read more the details.

In db_pool.js I wanted to gather methods for creating a connection to databases. If I had mysql as databases I would have posted it here.

I used "redis": "^0.12.1", "underscore": "^1.8.2", "websocket": "^1.0.17", "yargs": "^3.5.4" you can see the dependencies in package.json.

For create the chat server you have to get instanse and call the method init_jsonrpc() as the example:

var ChatCreator=require('chatserver');

var ChatServer=ChatCreator.getInstance(); ChatServer.init_jsonrpc();