# server-suit

> Tool to run multiple hosts on a single IP and compose HTML with variables on the server side

Latest version **2.0.0** (published 2023-09-07) · 0 weekly downloads

## Install

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

## Health

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

Positive: no vulnerabilities; high maintenance score.

Warnings: low downloads; no types; no esm support.

Negative: abandoned.

## Facts

| | |
|---|---|
| Version | 2.0.0 |
| Published | 2023-09-07 |
| First published | 2019-02-19 |
| Weekly downloads | 0 |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 46.4 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Trevor Ranney |
| Maintainers | trevorranney |

## Links

- npm: https://www.npmjs.com/package/server-suit
- Repository: https://github.com/TrevorRanney/suit
- Homepage: https://github.com/TrevorRanney/suit#readme
- Issues: https://github.com/TrevorRanney/suit/issues
- npm.io page: https://npm.io/package/server-suit

## Recent versions

- 2.0.0 (latest) — 2023-09-07
- 1.0.7-alpha.1 (alpha) — 2019-09-27
- 1.0.10 — 2020-08-10
- 1.0.9 — 2020-08-10
- 1.0.8-alpha.1 — 2020-03-27
- 1.0.7-alpha.0 — 2019-09-27
- 1.0.6 — 2019-07-21
- 1.0.5 — 2019-06-06
- 1.0.4 — 2019-02-22
- 1.0.3 — 2019-02-22
- 1.0.2 — 2019-02-20
- 1.0.1 — 2019-02-19
- 1.0.0 — 2019-02-19

## README

# 🕴️ Server Suit 🕴️
* Runs many hosts on a single IP address
* Explicitly serves files
* Interpolates javascript objects into html variables on the server side  
[Check out this example for server side html with variables](/example/complex-data) 
* Load components 

### Install:
``` 
npm i server-suit 
```

## Code example:
```
var Suit = require('server-suit');

var server = new Suit();

serveStuff = (request,response) => {
    response.end("HELLO WORLD");
}

serveDifferentStuff = (request,response) => {
    response.end("XD <3 XD");
}

var router = server.newRouter('testRouter');
router.addRoute('/', serveDifferentStuff);

router.addRoute('/file', "this/could/be/a/path/to/a/file");
var variables = { things: { stuff: ['XD']}, thing2: "thing2" };
router.addRoute('/variables', 'variables.html', {variables} );
// HTML file: <div>{{variables.things.stuff[0]}}</div>
// will apear as <div>XD</div> to the client

server.httpPort = 8888;  
server.addHost("localhost:8888", serveStuff);  
server.addHost("127.0.0.1:8888", router.serve);    


server.start();
```
## Components
Components can be loaded in an html file like this:
``` [[/path-to-file.html]] ```

## Running the example servers
Download this repo and run these commands to see examples of the server.  
This server requires no packages to run just node!
```
npm run router-example
 - localhost:3456
npm run complex-example
 - localhost:4567
```

## Running tests
The tests dependes on these packages to run  
    c8  
    jasmine  
    testcafe  
    concurrently
    
```
npm i
npm test
```
Run just the unit test
```
npm run unit
```

Run just the e2e tests
```
npm run e2e
```

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