@siteone/serve-static
v0.0.20
Published
Server for static projects which don't need SSR but could use all the other goodies.
Downloads
4
Keywords
Readme
serve-static
Static app server with option to pass enviroment variables from
.env
files into the browser-only app in a little more secure way than just inlining them into html.
CLI
Usage
$ serve-static serve [options]
Options
-v, --views
- Path to views folder containing HTML files. Will use index.html for any route without extension. Looks for status code templates for edge cases (404.html, 500.html...) (default
./build-static
)
- Path to views folder containing HTML files. Will use index.html for any route without extension. Looks for status code templates for edge cases (404.html, 500.html...) (default
-r, --publicRoot
- Path to public root folder (default
./build-static
)
- Path to public root folder (default
-e, --env
- Path to enviroment variables (
.env
file) which will be inlined into served html template (default./.env
)
- Path to enviroment variables (
-l, --logs
- Path to logs (default
./logs
)
- Path to logs (default
- Pass
false
to disable logging
- Pass
-p, --port
- Port to run server on (default
8888
)
- Port to run server on (default
-h, --host
- Application host (default
0.0.0.0
)
- Application host (default
-i, --include
- Include only specified variables from env file to browser ex:
srvr-static --include=API_KEY,CLIENT_ID
- Include only specified variables from env file to browser ex:
-h, --help
- Displays this message
Examples
$ serve-static srvr-static serve --views ./build-static --publicRoot ./build-static --env ./.env --logs ./logs --port 5050 --host 0.0.0.0 --include=API_KEY,CLIENT_ID
Programmatic
Usage
const path = require('path')
const serveStatic = require('@siteone/serve-static')
const opts = {
views: path.resolve('./static'),
publicRoot: path.resolve('./static'),
env: path.resolve('./.env'),
logs: false,
host: '0.0.0.0',
port: 8080,
include: ['NODE_ENV', 'API_KEY', 'WHATEVER']
}
serveStatic(opts)