# comets

> Create a one-off server for testing

Latest version **1.0.0** (published 2020-03-21) · MIT license · 0 weekly downloads

## Install

```sh
npm install comets
pnpm add comets
yarn add comets
bun add comets
```

## Health

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

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.0 |
| Published | 2020-03-21 |
| First published | 2020-03-21 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 4.6 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 2 |
| Maintainers | amio |

## Links

- npm: https://www.npmjs.com/package/comets
- Repository: https://github.com/amio/comets
- Homepage: https://github.com/amio/comets#readme
- Issues: https://github.com/amio/comets/issues
- npm.io page: https://npm.io/package/comets

## Recent versions

- 1.0.0 (latest) — 2020-03-21
- 0.0.0 — 2020-03-21

## README

# comets

[![npm version][npm-src]][npm-href]
[![package size][size-src]][size-href]

Create a one-off server for testing http request listener.

## Usage

```bash
npm install comets
```

```js
import assert from 'assert'
import fetch from 'node-fetch'
import { createServer } from 'comets'

async function test () {
  // The handler to test
  const requestHandler = (req, res) => res.end('yo')

  // Create a one-off server for testing
  const address = await createServer(requestHandler)

  // Send test request, the server will close after this request
  const result = await fetch(address).then(res => res.text())

  assert.equal(result, 'yo')
}
```

## API

### `createServer()`

`async createServer(handler: http.RequestListener, count: number = 1) => Promise<string>`

- __`handler`__: the request listener for creating http server
- __`count`__: the number of requests allowed before server closed (default: 1)

returns __`Promise<string>`__: the server address (`http://localhost:<PORT>`).

## License

[![License][license-src]][license-href]


[npm-src]: https://badgen.net/npm/v/comets
[npm-href]: https://www.npmjs.com/package/comets
[size-src]: https://badgen.net/packagephobia/install/comets
[size-href]: https://packagephobia.now.sh/result?p=comets
[license-src]: https://badgen.net/badge/license/MIT
[license-href]: LICENSE.md

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