# @fvilers/listen-once

> A Node.js web server that listen only once

Latest version **1.0.0** (published 2023-07-13) · MIT license · 0 weekly downloads

## Install

```sh
npm install @fvilers/listen-once
pnpm add @fvilers/listen-once
yarn add @fvilers/listen-once
bun add @fvilers/listen-once
```

## Health

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

Positive: has types; esm support; no vulnerabilities.

Warnings: low downloads.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.0 |
| Published | 2023-07-13 |
| First published | 2023-07-13 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 0 |
| Unpacked size | 6 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Fabian Vilers |
| Maintainers | fvilers |
| Keywords | typescript, web, server, typescript-library |

## Links

- npm: https://www.npmjs.com/package/@fvilers/listen-once
- Repository: https://github.com/fvilers/listen-once
- Homepage: https://github.com/fvilers/listen-once#readme
- Issues: https://github.com/fvilers/listen-once/issues
- npm.io page: https://npm.io/package/@fvilers/listen-once

## Alternatives

- [@opentelemetry/exporter-zipkin](https://npm.io/package/@opentelemetry/exporter-zipkin.md) — 14.8M weekly downloads
- [pusher-js](https://npm.io/package/pusher-js.md) — 2.0M weekly downloads
- [browserify](https://npm.io/package/browserify.md) — 1.7M weekly downloads
- [sqs-consumer](https://npm.io/package/sqs-consumer.md) — 1.7M weekly downloads
- [@sanity/eventsource](https://npm.io/package/@sanity/eventsource.md) — 930.8K weekly downloads

## Recent versions

- 1.0.0 (latest) — 2023-07-13

## README

# listen-once

A Node.js web server that listen only once

## Purpose

This library expose a simple method that spins a web server that accept only one request. It can be used to retrieve a query string parameter or body from a authorization redirect (OAuth 2 for example).

# ECMAScript module

This library is published as an ECMAScript module.

## Usage

```typescript
import http from "node:http";
import { listenOnce } from "@fvilers/listen-once";

const PORT = 3000;
const HOSTNAME = "localhost";

function onListening() {
  console.log("Server listening on", `http://${HOSTNAME}:${PORT}`);
}

function onRequest(req: http.IncomingMessage, res: http.ServerResponse) {
  console.log("Incoming request", req.url);

  // TODO: do something with the request

  res.statusCode = 200;
  res.end();
}

await listenOnce(PORT, HOSTNAME, onListening, onRequest);

console.log("Server closed");
```

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