An open API service indexing awesome lists of open source software.

https://github.com/roxiness/spassr


https://github.com/roxiness/spassr

Last synced: 11 months ago
JSON representation

Awesome Lists containing this project

README

          


routify

### Small Express server with SSR

#### Usage example

$ npx spassr --assets-dir dist --entrypoint dist/index.html --script dist/build/bundle.js --ssr

#### Configuration

Spassr can be configured through `CLI`, `package.json`, `spassr.config.js` and `.env`.

Environment variables are converted from snake_case to camelCase, so `SPASSR_assets_dir = dist` becomes `{... assetsDir: 'dist'}`

For configuration options, refer to the API below.

* * *

### API

##### Table of Contents

- [spassr](#spassr)
- [Parameters](#parameters)
- [Config](#config)
- [Properties](#properties)
- [Eval](#eval)
- [Parameters](#parameters-1)
- [config](#config-1)

#### spassr

##### Parameters

- `options` **Partial<config.Config>** \*

#### Config

Type: [object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)

##### Properties

- `assetsDir` **([string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String) \| [Array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array)<[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)>)** folders with static content to be served.
- `entrypoint` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** HTML template, eg. assets/index.html.
- `script` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** path to app, eg. build/bundle.js.
- `port` **([string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String) \| [number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number))** port to serve on.
- `ssr` **[boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)** enable SSR for routes not resolved in assetsDir.
- `silent` **[boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)** quiet console.log.
- `middleware` **[Function](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Function)** function to customize SPA server (_Not available in CLI_).
- `ssrOptions` **Partial<tossr.Config>** options to pass to ssr.

#### Eval

Called before/after the app script is evaluated

Type: [Function](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Statements/function)

##### Parameters

- `dom` **[object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)** The DOM object

#### config

Type: [Config](#config)

---

Business vector created by teravector - www.freepik.com