Skip to content

justinrlle/spa-server

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

23 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

spa-server

A simple cli tool to serve a folder containing a SPA application, with basic proxy capabilities.

Features

  • serve from a folder using cli args or a config file
  • respond to html requests with the root index.html
  • serve from a tar archive (the tar executable must be present)
  • serve from an url pointing to a tar archive (soon™)
  • proxy some calls to other apps (à la webpack dev-server proxy, but with less features)
  • use ~ and environnement variables in application path

Example

Assuming an angular v8 app called project-name, and built with ng build.

In one line:

$ spa-server -s dist/project-name
# will serve the folder dist/project-name on http://localhost:4242

Using a config file

If you want to have proxies, customize the host or the port, you must use a config file. Given one called Spa-project-name.toml:

[server]
port = 4200
serve = "~/git/project-name/dist/project-name" # support for `~` in paths

[proxies]
"/api" = { target = "http://localhost:8080" }
# example: http://localhost:4200/api/hello will be forwarded to http://localhost:8080/api/hello

Just run spa-server Spa-project-name.toml and you're ready to go!

For a complete documentation about the config file, your best bet right now is the documentation of the Config struct.

Installation

Compile from sources

First, Rust must be installed. You can then install this binary from git:

$ cargo install --force --git https://github.com/justinrlle/spa-server

Install from crates.io

TODO

TODO (and current caveats)

TODO soon

  • serve from url

long term TODOs

  • other protocols
    • s3 (aws-cli or rusoto?)
    • ftp
    • ssh?
    • git?
  • windows support for archives
  • better testing for archives
  • feature parity with webpack dev-server proxy
  • cli option to define simple proxies (possible syntax: spa-server --forward /api=http://localhost:8080)
  • figure out how to use secrets in application path
    • stay with plain old environnement variables and dotenv file loading?
    • use of secret-tool, gnome-keychain, Keychain Access on macOS?

About

A tiny server for serving local SPAs

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages