MozillaReality / fxr-cli

INACTIVE - A command-line tool for installing and automating the Firefox Reality virtual-reality browser.
https://www.npmjs.com/package/fxr
Mozilla Public License 2.0
4 stars 3 forks source link

serve local Node server in `launch` for projects on user's local filesystem #5

Closed cvan closed 2 months ago

cvan commented 6 years ago

currently, only URLs are allowed. we should also support spawning a local server if a local file path is passed as the URL/path.

example usage:

this should help a ton with local development.

  1. npm i --save live-server live-server-https
  2. then add something like this to commands/launch.js:

    const tls = require('tls');
    const https = require('live-server-https');
    const PORT = SETTINGS.dev_port || 8080;
     const server = tls.createServer(https, (socket) => {
      console.log(`Server connected: ${socket.authorized ? 'authorized' : 'unauthorized'}`);
      socket.write('Greetings!\n');
      socket.setEncoding('utf8');
      socket.pipe(socket);
    });
    server.listen(PORT, () => {
      console.log(`Running local server on port ${PORT}`);
    });