@leichtgewicht/quickhost
Hosts html files temporarily based on a max amount of size in a LRU cache. Allows upload using secret keys.
Last updated 6 months ago by leichtgewicht .
MIT · Original npm · Tarball · package.json
$ cnpm install @leichtgewicht/quickhost 
SYNC missed versions from official npm registry.

Quickhost

Server and upload-client to quickly host a single static html page - useful for browserstack test.

Motivation

To test JavaScript code running in a browser, browserStack offers a good test platform but the selenium tests require the html files to be available in the internet. The problem is if you have files locally: how can you make them accessible by browserstack?

This is a simple http hosting server that - using a secret - allows to upload any given html file and hosts it for a limited amount of time. It also has a limit on amount of files to be hosted which means it cleans up after itself.

Start a server

Prerequisites: Node running!

$ env \
    QUICKHOST_SECRET=$(node -p "crypto.randomBytes(8).toString('hex')") \
    QUICKHOST_MAX=10 # (optional) Max number of html files to be hosted - default 10 \
    QUICKHOST_MAX_SIZE=3145728 # (optional) Max number of bytes of a file to be hosted - default 3 Megabytes \
    PORT=1234 # (optional) Port where the server will connect to - default 1234 \
    HOST=localhost # (optional) Host where the server will connect to - default 0 \
    npx quickhost

Important note: You should run nginx and letsencrypt to have turn the server into an https server.

Upload

Once the server is running you can upload and download files from that server using a simple API:

  1. npm install @leichtgewicht/quickhost
  2. const upload = require('quickhost')
    const download = require('node-fetch')
    const server = 'https://quickhost.my-host.com'
    
    const key = await upload({
      server, // Server url where the quickhost server is running
      secret: 'secret-from-server', // Secret used when starting the quickhost server
      data: '<html><b>Hello World</b></html>', // Data to be uploaded to the quickhost server
      timeout: 5000 // Timeout for the upload
    })
    
    const data = await fetch(`${server}/${key}`) // Now we can download the server
    

License

MIT

Current Tags

  • 1.1.0                                ...           latest (6 months ago)

2 Versions

  • 1.1.0                                ...           6 months ago
  • 1.0.0                                ...           6 months ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 2
Last Day 0
Last Week 0
Last Month 0
Dependencies (2)
Dev Dependencies (5)
Dependents (0)
None

Copyright 2014 - 2016 © taobao.org |