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

upload-server-1

v3.0.0

Published

(not so) Simple HTTP file upload server

Downloads

11

Readme

Upload server

This is not-as-simple-as-it-once-was service, that you can run on your VM to upload files. Also, it allows you:

  • watch log files on your VM (like tail -f but inside your browser (or use the web-socket API, described below)).
  • execute commands on VM (from browser or using the API)

API

Internal application API

HTTP

Get information about the current configuration of the upload-server.

GET /api/config

Log Watcher

HTTP

Get list of all log files, that can be watched.

GET /api/log-watcher/log

Allow watching the log file with the specified "absolutePath". This endpoint is only available while running the server in -admin mode.

POST /api/log-watcher/log

{"absolutePath": <path to log>}

Disallow watching the log file with the specified "absolutePath". This endpoint is only available while running the server in -admin mode.

DELETE /api/log-watcher/log?absolutePath=<path to log>

Get size of the log file with the specified "absolutePath". Only size of log files, returned by GET /api/log-watcher/log, can be obtained.

GET /api/log-watcher/log/size?absolutePath=<path to log>

Get content of the log file with the specified "absolutePath". Only content of log files, returned by GET /api/log-watcher/log, can be obtained. By default, returned content is split into an array of lines. To return content as a single string, specify "noSplit=true". Otherwise, "noSplit" parameter is optional and can be omitted.

GET /api/log-watcher/log/content?absolutePath=<path to log>&noSplit=<true/false>

Web Socket

Legacy

Works just like in the previous versions.

Connect to the endpoint.

/

Send "watch" message to watch changes in a log file:

{
  "type": "watch",
  "file": "<absolute path to log file>",
  "fromStart": true
}

"fromStart" parameter is optional and can be omitted. Specify it set to "true" if you want to read existing contents of the file before receiving updates about changes in it.

Only log files, returned by GET /api/log-watcher/log, can be watched.

To stop watching changes in a log file - use "unwatch" message:

{
  "type": "unwatch",
  "file": "<absolute path to log file>"
}
Default

Connect to the endpoint of the log file, you want watch.

/api/log-watcher/log?absolutePath=<path to log>&fromStart=<true/false>

"fromStart" parameter is optional and can be omitted. Specify it set to "true" if you want to read existing contents of the file before receiving updates about changes in it.

Only log files, returned by GET /api/log-watcher/log, can be watched.

Command Executor

HTTP

Get list of all commands, that can be executed.

GET /api/command-executor/command

Create a new command. This endpoint is only available while running the server in -admin mode.

POST /api/command-executor/command

{"name": "<name of the command>", "script": "<actual shell script command>"}

Delete a command. History of all of this command's executions will be deleted as well. This endpoint is only available while running the server in -admin mode.

DELETE /api/command-executor/command/<command ID>

Get history of all executions of all commands. Command execution output is not returned by this endpoint.

GET /api/command-executor/execution

Delete all executions (both active and complete).

DELETE /api/command-executor/execution

Get history of all executions of the specified command. Command execution output is not returned by this endpoint.

GET /api/command-executor/command/<command ID>/execution

Execute specified command.

POST /api/command-executor/command/<command ID>/execution

Get information about the specified command execution. The response will contain executions output. "noSplit" parameter is optional and can be omitted. Be default output of the command is returned as an array of lines. Specify "noSplit=true" in order to return the output as a single string.

GET /api/command-executor/command/<command ID>/execution/<execution start time>?noSplit=<true/false>

Delete information about the specified command execution.

DELETE /api/command-executor/command/<command ID>/execution/<execution start time>

Gracefully terminate specified execution of the command.

POST /api/command-executor/command/<command ID>/execution/<execution start time>/terminate

Forcefully terminate specified execution of the command.

POST /api/command-executor/command/<command ID>/execution/<execution start time>/halt

Web Socket

Connect to this endpoint if you want to receive notifications about all command-related events.

/api/command-executor/event

Connect to this endpoint if you want to receive notifications about all status change events of all executions.

/api/command-executor/event/status

Connect to this endpoint if you want to receive notifications about all events, related to the specified command execution.

/api/command-executor/command/<command ID>/execution/<execution start time>

Connect to this endpoint if you want to receive notifications about status change of the specified command execution.

/api/command-executor/command/<command ID>/execution/<execution start time>/status

Connect to to this endpoint if you want to receive notifications about changes in the output (STDOUT and STDERR) of the specified command execution. "fromStart" parameter is optional and can be omitted. Specify it set to "true" if you want to read existing output of the command before receiving updates about changes in it.

Notice: normally this endpoint only allows to watch output of an active execution. Attempts to watch output of a complete execution will fail. BUT, if you specify "fromStart" set to "true" you would be able to "watch" output of a complete execution as well. In such case you will immediately receive all the output of the execution and then the connection will immediately close.

Rationale: if you are watching output with "fromStart" not set or set to "false" - most likely you don't want to receive the entire output of the execution (either it is too big or some other thing). Watching an output of the complete execution in such case does not make sense since the execution is already over and you will not receive any events anyway. On the other hand, the behavior related to the "fromStart" set to "true", simplifies the cases when you just want to watch the entire output of the execution: you would not need to consider if the execution is complete or not, there will be no race conditions when you check if execution is active, try to watch it's output but it has already finished in between those two network calls, yada-yada-yada...

/api/command-executor/command/<command ID>/execution/<execution start time>/output?fromStart=<true/false>

Uploader

HTTP

Notice: all endpoints of this API require Basic authentication. Use credentials, displayed in the log during the startup, as a username:password combination.

Upload a file with 'multipart/form-data' content-type. A body should have two attributes:

  • file - a path, where the file should be saved
  • data - actual body of the file
POST /api/uploader/file
or
POST /files/upload
or
POST /files/

Upload a file. A body of a request should contain body of the file.

POST /api/uploader/file?name=<path, where the file should be saved>
or
POST /files/upload?file?name=<path, where the file should be saved>
or
POST /files/?file?name=<path, where the file should be saved>

Move file from one location to another. Can also be used to rename a file.

PUT /api/uploader/file

{"oldPath": "<current path to the file>", "newPath": "<new path to the file>"}
or
POST /files/move?old_file=<current path to the file>&file=<new path to the file>

Delete file.

DELETE /api/uploader/file?name=<current path to the file>
or
POST /files/delete?file=<current path to the file>