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 🙏

© 2026 – Pkg Stats / Ryan Hefner

file-ws-server

v1.0.0

Published

Server which manage repository for TwiceCast project

Readme

Build Status

FileWSServer

A server which transfer files through websockets

Synopsis

This server is created for the TwiceCast project, an Epitech Innovativ Project, it will be used by the streamer to transfer his source code for the viewers.

Installation

You can install it with :

npm install file-ws-server

You can launch it with :

npm start [port number]

Configuration

You can create a config.json file for some parameters. Here is an example :

{
  "port":Port number,
  "baseDir":"Path/to/receive/files",
  "key":"Secret key for JWT"
}

port is used when not in argument. By default, it is set to 3005.

baseDir is used to set the directory where files will be transfered. By default, it is set to "./".

key is used to set the key signature that will be used to verify the token of the client. By default, it is set to "secret".

Protocol

Template message

The basic template message to send is :

{
  "type":"The part of the server aimed",
  "subtype":"The functionnality of the part aimed",
  "data" : {
  }
}

Authentication

WARNING: This part is not functionnal

For using certains parts of the server (like posting files), you must be authentified.

You can do that by sending :

{
  "type":"authenticate",
  "data":{
    "token":"your token"
  }
}

File part

Auth for file

When a streamer use this part, he has to authenticate by sending :

{
	"type":"file",
	"subtype":"auth",
	"data": {
		"username":"streamer's username",
		"project":"streamer's project"
	}
}

In case of success, response will be :

{
	"code":200,
	"type":"fileAuth",
	"data":"OK"
}

Get file

You can get a file, a directory or a complete project by sending :

{
	"type":"file",
	"subtype":"get",
	"data": {
		"username":"streamer's username",
		"project":"streamer's project",
		"name":"/path/to/file or directory aimed",
		"recursively":false
	}
}

name parameters can be ommited to get the entire project.

By default, recursively is set to false.

In case of success, responses will be :

{
	"code":200,
	"type":"fileGet",
	"data": {
		"name":"/path/to/file",
		"content":"content of a part of the file",
		"part":part number,
		"maxPart":number of part that will be sent
	}
}

Post file

Streamer authentified can post a file by sending :

{
	"type":"file",
	"subtype":"post",
	"data": {
		"name":"/path/to/file aimed",
		"content":"content of a part of the file",
		"part":part number,
		"maxPart":number of part that will be sent
	}
}

part and maxPart can be ommited when sending the complete content.

The file will be saved at config.baseDir/sender.username/sender.project/message.data.name.

In case of success, response will be :

{
	"code":200,
	"type":"filePost",
	"message":"OK"
}

Delete file

Streamer authentified can delete a file by sending :

{
	"type":"file",
	"subtype":"delete",
	"data": {
		"name":"/path/to/file aimed"
	}
}

In case of success, response will be :

{
	"code":200,
	"type":"fileDelete",
	"message":"OK"
}

Chat part

Auth for chat

When a user use this part, he must be authentified by sending :

{
	"type":"chat",
	"subtype":"auth",
	"data": {
		"username":"user's username",
		"room":"user's room (can be the stream's name coupled with streamer's name)"
	}
}

In case of success, response will be :

{
	"code":200,
	"type":"chatAuth",
	"data":"OK"
}

Message

A user authentified can send a message to his room by sending :

{
	"type":"chat",
	"subtype":"message",
	"data": {
		"message":"Content of the message"
	}
}

In case of success, response will be :

{
	"code":200,
	"type":"chatMessage",
	"data":"OK"
}