Ecosyste.ms: Awesome

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

Awesome Lists | Featured Topics | Projects

https://github.com/robojones/var-server


https://github.com/robojones/var-server

Last synced: 23 days ago
JSON representation

Awesome Lists containing this project

README

        

# var-server

This module provides you with a simple server http server.
It can be used to write tests e.g. for worker processes in a cluster.

## In the worker process

```javascript
require('var-server')(8080).listen()
```

__Note:__ The server listens on `127.0.0.1`, so it is only accessible on the same computer.

## In the test file

```javascript
const s = require('var-server')(8080)

s.run('process.argv').then(argv => {
console.log(argv) // the argv from the test process
})
```

The code in the .get() method gets executed with `eval()` in the worker process.

```javascript
const s = require('var-server')(8080)

s.run('process.cwd()').then(cwd => {
console.log(cwd)
})
```