@siteone/serve-static

0.0.20 • Public • Published

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)
  • -r, --publicRoot
    • Path to public root folder (default ./build-static)
  • -e, --env
    • Path to enviroment variables (.env file) which will be inlined into served html template (default ./.env)
  • -l, --logs
    • Path to logs (default ./logs)
    • Pass false to disable logging
  • -p, --port
    • Port to run server on (default 8888)
  • -h, --host
    • Application host (default 0.0.0.0)
  • -i, --include
    • Include only specified variables from env file to browser ex: srvr-static --include=API_KEY,CLIENT_ID
  • -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)

Readme

Keywords

none

Package Sidebar

Install

npm i @siteone/serve-static

Weekly Downloads

0

Version

0.0.20

License

MIT

Unpacked Size

8.52 kB

Total Files

3

Last publish

Collaborators

  • siteonecz
  • hlavo-siteone
  • viktorbezdek
  • jiri.cerhan