# approvals-server

> HTTP server for running approvals from the browser

Latest version **0.4.0** (published 2021-05-09) · Apache license · 0 weekly downloads

## Install

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

## Health

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

Positive: no vulnerabilities.

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

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.4.0 |
| Published | 2021-05-09 |
| First published | 2015-02-20 |
| Weekly downloads | 0 |
| License | Apache |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 2 |
| Unpacked size | 4.1 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 3 |
| Author | Kristoffer Ahl |
| Maintainers | kristofferahl |
| Keywords | approvaltests, approvals, tests, server |

## Links

- npm: https://www.npmjs.com/package/approvals-server
- Repository: https://github.com/kristofferahl/approvals-server
- Homepage: http://approvaltests.com
- Issues: https://github.com/kristofferahl/approvals-server/issues
- npm.io page: https://npm.io/package/approvals-server

## Dependencies (2)

- [bl](https://npm.io/package/bl.md) ^1.2.3
- [approvals](https://npm.io/package/approvals.md) ^1.3.x

## Recent versions

- 0.4.0 (latest) — 2021-05-09
- 0.3.0 — 2021-05-09
- 0.2.0 — 2016-10-17
- 0.1.2 — 2015-04-23
- 0.1.1 — 2015-02-20
- 0.1.0 — 2015-02-20

## README

# approvals-server [![NPM version](https://badge.fury.io/js/approvals-server.png)](http://badge.fury.io/js/approvals-server)
A simple node HTTP server for running approval tests from the browser.

## Install

If you use npm, then install the package via npm.

    npm install approvals-server

If you're not using npm, simply copy the file `index.js` to a directory of your choice.

## Server setup

	var approvalsServer = require('approvals-server')();

### Configuring the server

	var approvalsServer = require('approvals-server')({
		approvals: {},		// See https://github.com/approvals/Approvals.NodeJS#config-override for all config options
		port: 1338,			// Default port
		path: './'			// Default path
	});

If you need to you can manipulate the filenames by overriding the testNamer function like this:

	var config = {
		testNamer: function (name) {
			return name.replace(/\W+/g, '-');
		}
	}

## Verify

To verify, do a POST to "http://localhost:1339/verify".

Parameters:

	{
	  "testName": "The name of the test",
	  "data": "String to compare"
	}

### From the browser

The simplest thing possible is to do something like this.

	function verify(test, data) {
		var xhr = new XMLHttpRequest();
		xhr.open('post', 'http://localhost:1339/verify', false);
		xhr.send(stringify({ testName: test, data: data }));
		return xhr.status === 200;
	}

	var data = {
		"Name": "Kristoffer",
		"Age": "Unknown"
	};

	verify('MyTest', JSON.stringify(data, null, 2));

### Using curl

	curl -H "Content-Type: application/json" -d '{ "testName": "Footest", "data": "Bar" }' http://localhost:1338/verify

### More about Approvaltests

http://approvaltests.com

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