Skip to content

Commit

Permalink
Removes ngrok capabilities
Browse files Browse the repository at this point in the history
  • Loading branch information
lukejacksonn committed Nov 7, 2019
1 parent 8064a6e commit 87e0845
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 52 deletions.
3 changes: 0 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,4 @@
*.pem
*.crt

ngrok.yml
ngrok.token

.DS_Store
5 changes: 1 addition & 4 deletions .npmignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,4 @@ test

*.key
*.pem
*.crt

ngrok.yml
ngrok.token
*.crt
12 changes: 4 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

> A dependency free dev server for modern web application development
The new and enhanced version of [http-server-spa](https://npmjs.com/http-server-spa). A very compact but capable static file server with https, live reloading and other useful features to support web app development on localhost and over a network.
The new and enhanced version of [http-server-spa](https://npmjs.com/http-server-spa). A very compact but capable static file server with https, live reloading and other useful features to support web app development on localhost and over a local network.

Servør can be invoked via the command line or programmatically using the node API.

Expand All @@ -17,8 +17,8 @@ The motivation here was to write a "close to the metal" package from the ground
- 🗂 Serves static content like scripts, styles, images from a given directory
- 🖥 Redirects all path requests to a single file for frontend routing
- ♻️ Reloads the browser when project files get added, removed or modified
- 🔐 Supports https with self signed and trusted certificates
- 🚇 Generates secure public urls for localhost using ngrok
- 🔐 Supports https with self signed certificates added to the systems trusted store
- 🔎 Finds available ports to run on if no port is provided

## CLI Usage

Expand Down Expand Up @@ -52,10 +52,6 @@ Example usage with npm scripts in a `package.json` file after running `npm i ser
}
```

### Creating a public url

Once the process has started, hit the return key in the terminal window; this will cause [`tunnel.js`](/tunnel.js) to be ran which invokes ngrok via `npx`. A public url will be logged out as soon as a connection has been established.

### Generating Credentials

> NOTE: This process depends on the `openssl` command existing (tested on macOS only)
Expand All @@ -68,7 +64,7 @@ When servor is invoked with the `--secure` flag, it looks for two files `servor.
- a public certificate (crt) that the server sends to clients
- a private key for the certificate (key) to encrypt and decrypt traffic

If these steps are all successful then the server will start using https. The credentials are valid but are still not trusted, which means that when the server is opened in the browser for the first time there is likely to be a warning displayed which needs to be acknowledged before continuing. Once the warning has been dismissed once it should not return unless the credentials are regenerated.
If these steps are all successful then the server will start using https. The credentials are valid but are still not trusted, which means that when viewed in the browser for the first time there is likely to be a warning displayed. Dismiss the warning and it should not return unless the credentials are regenerated.

#### Adding credentials to the trusted store

Expand Down
14 changes: 2 additions & 12 deletions cli.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#!/usr/bin/env node
const fs = require('fs');
const servor = require('./servor.js');
const tunnel = require('./tunnel.js');

const readCredentials = () => ({
cert: fs.readFileSync(__dirname + '/servor.crt'),
Expand Down Expand Up @@ -61,20 +60,11 @@ const open =
console.log(`
🗂 Serving:\t${root}\n
🏡 Local:\t${url}
${ips.map(ip => `📡 Network:\t${protocol}://${ip}:${port}`).join('\n ')}`);
${ips.map(ip => `📡 Network:\t${protocol}://${ip}:${port}`).join('\n ')}
`);

// Browser the server index

~process.argv.indexOf('--browse') &&
require('child_process').execSync(`${open} ${url}`);

// Start ngrok if the enter key is pressed

process.stdin.once('data', () =>
~process.argv.indexOf('--secure')
? console.log(' 🚧 Public:\tCannot tunnel with the --secure flag')
: tunnel(protocol, port).then(url =>
console.log(` 🌍 Public:\t\x1b[4m${url}\x1b[0m`)
)
);
})();
25 changes: 0 additions & 25 deletions tunnel.js

This file was deleted.

0 comments on commit 87e0845

Please sign in to comment.