# @xroom.app/http-listener

> Wrapper over standard http listener

Latest version **1.0.3** (published 2021-04-21) · MIT license · 0 weekly downloads

## Install

```sh
npm install @xroom.app/http-listener
pnpm add @xroom.app/http-listener
yarn add @xroom.app/http-listener
bun add @xroom.app/http-listener
```

## Health

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

Positive: no vulnerabilities.

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

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.3 |
| Published | 2021-04-21 |
| First published | 2020-12-12 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 6.8 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | awerlogus |
| Maintainers | xroom.app |
| Keywords | nodejs, http, listener, wrapper, xroom.app |

## Links

- npm: https://www.npmjs.com/package/@xroom.app/http-listener
- Repository: https://github.com/xroom-app/public-packages
- Homepage: https://github.com/xroom-app/public-packages/tree/master/packages/http-listener/#readme
- Issues: https://github.com/xroom-app/public-packages/issues
- npm.io page: https://npm.io/package/@xroom.app/http-listener

## Dependencies (1)

- [@xroom.app/events](https://npm.io/package/@xroom.app/events.md) ^1.0.0

## Recent versions

- 1.0.3 (latest) — 2021-04-21
- 1.0.2 — 2020-12-22
- 1.0.1 — 2020-12-12
- 1.0.0 — 2020-12-12

## README

# Wrapper over standard http listener

## This package is deprecated and will be deleted soon

## Installation

Run from command line

```
npm i @xroom.app/http-listener
```

## Usage example

```js
const { getRequestListener } = require('@xroom.app/http-listener')

const { events, eventSystem, listen } = getRequestListener()

eventSystem.on(events.requestReceived, ({ type, data, request, response }) => {
  if (type === 'json') {
    console.log('JSON request received: ', data)
    response.end('ok')
  } else {
    if (request.headers['content-type'] === 'application/json') {
      response.end('Invalid JSON passed')
    } else {
      response.end('JSON request required')
    }
  }
})

const server = listen(3000)
```

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