# downstream-server

> A cross-application server system designed for simple content servers.

Latest version **0.2.2** (published 2020-02-03) · 0 weekly downloads

## Install

```sh
npm install downstream-server
pnpm add downstream-server
yarn add downstream-server
bun add downstream-server
```

Provides the command `downstream`.

## Health

**Score 10/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; low quality score; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.2.2 |
| Published | 2020-02-03 |
| First published | 2020-01-31 |
| Weekly downloads | 0 |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 27.2 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Jesse Solomon |
| Maintainers | sir-panda-nugget |

## Links

- npm: https://www.npmjs.com/package/downstream-server
- npm.io page: https://npm.io/package/downstream-server

## Dependencies (1)

- [readline-sync](https://npm.io/package/readline-sync.md) ^1.4.10

## Recent versions

- 0.2.2 (latest) — 2020-02-03
- 0.2.1 — 2020-02-03
- 0.1.11 — 2020-02-03
- 0.1.10 — 2020-02-03
- 0.1.9 — 2020-01-31
- 0.1.8 — 2020-01-31
- 0.1.7 — 2020-01-31
- 0.1.6 — 2020-01-31
- 0.1.5 — 2020-01-31
- 0.1.4 — 2020-01-31
- 0.1.3 — 2020-01-31
- 0.1.2 — 2020-01-31
- 0.1.1 — 2020-01-31
- 0.1.0 — 2020-01-31

## README

# Downstream Server
A cross-application server system designed for simple content servers.

## Upcoming features
- HTTPS support
- HTTP header read/write access
- Reusable behaviours

## Example Server
Create a `provider.dsp` file and add the following:
```dsp
[/] => pass "<h1>Hello World!</h1>"
```

Then run: `down-serve` and visit "localhost"

## Basic Syntax

### Global Syntax
Comments are denoted by a `//`

Variables are accessed by an `@`, and can be reference as pointers with `&`.

### Stream declaration
URL handlers are denoted by `[...]`, and can contain a valid URL and variables.
```dsp
[/test/@var/item]
```

All streams require a behaviour.

### Behaviours
Behaviours are declare with an `=>`. Behaviours consist of actions, which are separated by `->`.

```dsp
=> log "This is a test" -> pass "Hello world!"
```

## Config
There are two types of configuration, environment config, and external commands

### Environment config
```dsp
config name value
```
Here's a full list of configurations, More will be added soon:

`root` : The directory to start in for file loading

`showErrors` : Controls whether errors are returned

`httpPort` : The HTTP port to listen on, defaults to `80`

### External declerations
Downstream supports calling terminal commands in place of built-in methods.
```dsp
extern cli_command method_name
```

Using an external command is identically to a built-in method.

```dsp
... -> my_command arg1 arg2 -> ...
```

## Method Reference
`!` : Denotes a breakpoint, this will halt execution and print out the current context. Execution will resume when return is pressed in the host console.

`log` ..._value_ : Writes text to the host console.

`pass` _body_ : Sets the response body value.

`decodeURI` _uri_ : Decodes a given URI. Example: `"Hello%20World!"` becomes `"Hello World!"`

`put` &_variable_ : Inserts the response body into a variable pointer.

`readFile` _filename_ : Inserts the contents of a file into the response body.

`populate` : Allows for the inserting of variables into the response body. Example `<h1>@title</h1>` become `<h1>Test</h1>` where @title is `Test`.

`split` _delimiter_ ..._pointers_ : Splits the response body by the _delimiter_ and maps the results to the pointers given.

---
_Source: https://npm.io/package/downstream-server · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
