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

hockit

v2.1.2

Published

HockIt is a super-simple HTTP file sharing server; it has a web GUI, a JSON API, and a CLI.

Downloads

14

Readme

HockIt File Server

HockIt is super-simple file sharing server software written in NodeJS; it has a web GUI, a JSON API, a CLI, and a standard I/O interface.

NPM

Install

Install the package globally to use the hockit executable:

npm i -g hockit

You can start a HockIt server in two commands.

  • Run hockit passwd to set the web GUI password.
  • Run hockit start to start the HTTP server.

The HockIt server should now be listening for HTTP requests on port 8080. Try it out by opening the HockIt web GUI via localhost

A .hockit directory containing the default configuration & webroot directory will be created in the current user's home folder.

For setting up HockIt with a HTTPS/SSL certificate, see SSL Configuration

Hock it up there!

You can upload files via CLI in a Terminal, HTTP in a web browser, or via a REST API.

Via HTTP

You can upload and list files via the web GUI. The default HTTP port is 8080, which you can change via hockit port. Before uploading & listing you must set a password via hockit passwd.

Via CLI

$ hockit up ~/Documents/hello.txt
http://my.website.com/p_9Gm

See CLI Commands

Via REST API

$ hockit token create helloworld
Generated new HockIt REST API token.
        helloworld -> hockitApiToken
$ curl http://my.website.com/up -F "[email protected]" -H "Authorization: hockitApiToken"
{"error":null,"data":{"files":[{"name":"myfile.png","hash":"0Z5kF","date":1585787847478}],"total":5}}

See REST API

CLI Commands

General Syntax: hockit <command> <parameter1> <parameter2>

File Server

  • list Lists all uploaded files and their shortlinks.
  • list <hash> Lists a single uploaded file using hash.
  • delete <hash> Deletes a file using hash.
  • up <path> Uploads a file and returns a shortlink to it.
  • start Starts the HockIt HTTP server on this session. If called via a TTY, a REPL session will be started to allow the input of additional commands while the HTTP server is running.

General Configuration

  • config Lists the current HockIt configuration status.
  • config reset Resets all configuration settings to default values and unsets all passwords.
  • passwd Sets the password for uploading/listing via the web GUI; supplying a blank password unset it and cause some web GUI features to stop working.
  • domain <fqdn> Sets the fqdn for use in generation of shortlink URLs.
  • port <uri> Binds the HTTP server to uri, which can be a port number, host, or socket/handle path.
  • webroot <path> Serves files from given path via the HTTP server. Requires both read & write permissions. The default webroot is located in ~/.hockit/webroot

SSL Configuration

Syntax: hockit ssl <option> <parameter>

Running hockit ssl without options will check the validity of the current SSL configuration.

  • enable Enables HTTPS/SSL and attempts to import the SSL PEM certificate & key files when hockit start is invoked.
  • disables Disables HTTPS/SSL and ignores any given certificate/key.
  • cert <path> Sets the filesystem path to the SSL PEM certificate file.
  • cert <unset> Unsets the filesystem path to the SSL PEM certificate file.
  • key <path> Sets the filesystem path to the SSL PEM private key file.
  • key <unset> Unsets the filesystem path to the SSL PEM private key file.
  • pass Sets the passphrase to the SSL PEM private key file via a TTY.
  • pass <passphrase> Sets the passphrase to the SSL PEM private key file via the standard I/O interface.
  • pass <unset> Unsets the passphrase to the SSL PEM private key file.

API Tokens

Syntax: hockit token <option> <parameter>

Running hockit token without options will list all valid API tokens and their nicknames.

  • list Lists all API tokens.
  • list <nickname> Searches for an API token usng nickname.
  • revoke <nickname> Permanently revokes an API token using nickname from service, denying all future API requests made with that token.
  • create <nickname> Creates and returns a new API token and indexes it using nickname.

REST API

Hockit implements a traditional REST API via the Get and Post HTTP request methods; response bodies are in JSON format, and are sometimes omitted in favor of HTTP status codes.

To access the API, you must supply a valid API token in the Authorization HTTP request header. API tokens can be generated and revoked via the CLI, see API Tokens

JSON Response

Tf the HTTP response body is present, it will contain a JSON string with an error property and a data property. If there was no error, then error will be set to null.

Routes

URL Syntax: my.website.com/<command>/<parameter>

  • /<hash> If a file is found which matches the hash, then GET returns the binary data. Returns HTTP error 404 if no file was found.
  • /up Uploads a file to the server and redirects to /uploads to display it. Excpets the request body to contain data of type multipart/form-data.
  • /list Lists all uploaded files and their hashes. Returns an array of objects with the properties name, and hash.
  • /list/<hash> Searches for a file using hash. Returns an object with the properties name, and hash.
  • /delete/<hash> Deletes a file using hash. Returns HTTP 200 on success, and HTTP 404 if the file does not exist.
  • /_healthcheck Simply returns an "OK" string. Useful for monitoring the HTTP server uptime and checking that it is operating as expected.