@kard/spa-server

v0.1.0-rc.1
  • Types
  • ESM
  • CJS

A simple NodeJS based server for SPA

License
ISC
Install Size
4.7 kB/-
Vulns
0
Published

Get started

$npm install @kard/spa-server
$pnpm add @kard/spa-server
$yarn add @kard/spa-server
$bun add @kard/spa-server
$deno add npm:@kard/spa-server
$vlt install @kard/spa-server
# Run locally
$npx @kard/spa-server
$pnpm exec @kard/spa-server
$npx @kard/spa-server
$bunx @kard/spa-server
$deno run npm:@kard/spa-server
$vlx @kard/spa-server

Readme

A simple NodeJS based server allows serving SPA applications with optional API proxy support and all-routes fallback. It developed to test SPA locally, with Puppeteer or Selenium-based frameworks.

Installation

npm add -D @kard/spa-server

Usage

spa-server --proxy=api::http://jsonplaceholder.typicode.com --port=3030 --public=public --fallback=index.html

The example above :

  • Will serve static files from ./public relative path, on port 3030.
  • Each file is absent will be replaced with ./public/index.html one.
  • All of the requests sent to /api/* routes will be redirected to http://jsonplaceholder.typicode.com base.

Command-line keys available

--proxy - allows setting API requests redirect (no default)

--port - allows setting the server port to use (default 3000)

--public - allows setting public path (default ./)

--fallback - allows setting fallback file name (default is index.html)

--route - allows setting base route of the app (default is none)

Weekly DownloadsAcross all versions

Versions