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-test-server

v2.1.0

Published

Small node server with a CLI to test file uploads.

Downloads

10

Readme

upload-test-server

Small node server with a CLI to test file uploads. Powered by hapi.

Why?

I searched for a simple and easy server that does just one thing:
Letting me test file uploads with front end gui stuff I work on.

Install

npm install -g upload-test-server

Run it

upload-test-server start

Starts the server on localhost:8989 and accepts file uploads at http://localhost:8989/upload.
By default all uploaded files are saved to the current working directory.
If the upload folder doesn't exist, it's created as soon as a file is uploaded.

See options for more

The server accepts any origin, so you shouldn't have any trouble with cors.
This also means don't use this stuff in production!

General usage

Usage: upload-test-server command


  Options:

    -V, --version  output the version number
    -h, --help     output usage information


  Commands:

    start [options]  Start the upload server.

Server options

Usage: start [options]

  Start the upload server.


  Options:

    -h, --host [host]         Host for the server. Defaults to localhost.
    -p, --port [port]         Port to listen on. Defaults to 8989.
    -s, --store [path]        Folder were uploads are stored. Defaults to cwd.
    -u, --uploadRoute [path]  Path of the upload route. Defaults to /upload.
    -m, --maxKb [kb]          Maximum file size in kilobytes. Defaults to 5120 KB.
    --image-processing [config file]  Process uploaded images. Supply path to config file for processing.
    -h, --help                output usage information

Example

Run at 127.0.0.1, port 1337, save uploads in ~/some/path. Upload url is http://127.0.0.1/uploadHere and the maximal accepted file size is 10240kb (10MB).

upload-test-server start -h 127.0.0.1 -p 1337 -s ~/some/path -u /uploadHere -m 10240

Image processing

The server can resize jpg and png files and/or generate multiple thumbnails.
In order to process images you need to provide a simple config file in json format.

The server currently only processes jpg and png files.

upload-test-server start --image-processing ./config.json

{
  "resize": {
    "maxWidth": 480,
    "maxHeight": 320
  },
  "thumbnails": [ 5, 100, 250, 500 ],
  "meta": true
}

resize

Resize the uploaded image to fit into the boundaries of

  • maxWidth pixels and
  • maxHeight pixels

thumbnails

An array pixel values for maximum height. The server creates a subdirectory for each size and saves the generated thumbnails with the same name as the full size image.

Example

{
  "thumbnails": [ 5, 100 ]
}

The server creates the following folder structure and files for each uploaded image:

/upload/my-image.jpg # Full size image
/upload/5/my-image.jpg # Image with height of 5 pixel and the correct pixels in with to keep ratio.
/upload/100/my-image.jpg # Image with height of 100 pixel and the correct pixels in with to keep ratio.

meta

If true then the server response includes meta data for images, like this.

{
  "channels": 3,
  "depth": "uchar",
  "format": "jpeg",
  "hasAlpha": false,
  "hasProfile": false,
  "width": 427,
  "height": 320,
  "space": "srgb"
}