# light-streamer

> streaming video/audio files to browser with http-range header

Latest version **0.0.2** (published 2022-02-04) · MIT license · 0 weekly downloads

## Install

```sh
npm install light-streamer
pnpm add light-streamer
yarn add light-streamer
bun add light-streamer
```

## 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.0.2 |
| Published | 2022-02-04 |
| First published | 2022-02-03 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 2 |
| Unpacked size | 16.3 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Abdullah Altahery |
| Maintainers | kernelcode |
| Keywords | node, express, stream |

## Links

- npm: https://www.npmjs.com/package/light-streamer
- Repository: https://github.com/KernelCode/light-streamer
- Homepage: https://altahery.com
- Issues: https://github.com/KernelCode/light-streamer/issues
- npm.io page: https://npm.io/package/light-streamer

## Dependencies (2)

- [throttle](https://npm.io/package/throttle.md) ^1.0.3
- [mime-types](https://npm.io/package/mime-types.md) ^2.1.34

## Alternatives

- [@expo/fingerprint](https://npm.io/package/@expo/fingerprint.md) — 6.2M weekly downloads
- [@azure/monitor-opentelemetry-exporter](https://npm.io/package/@azure/monitor-opentelemetry-exporter.md) — 850.0K weekly downloads
- [@azure/monitor-opentelemetry](https://npm.io/package/@azure/monitor-opentelemetry.md) — 624.0K weekly downloads
- [@posthog/ai](https://npm.io/package/@posthog/ai.md) — 423.3K weekly downloads
- [fakefilter](https://npm.io/package/fakefilter.md) — 63.9K weekly downloads

## Recent versions

- 0.0.2 (latest) — 2022-02-04
- 0.0.1 — 2022-02-03

## README

# [light-streamer](http://altahery.com/light-streamer)

A JavaScript library for streaming video/audio files to browser with http-range header

## Node.JS

```js
const { Streamer } = require("light-streamer");

Streamer.config({
  streamBy: "headers",
  badwidthLimit: 300,
  resourceURI: __dirname + "/videos",
});
/*
  avengers.mp4
  bunny.mp4
  ...
  
*/
Streamer.stream("/stream/:video", (error, file, streamConfig, params) => {
  if (error.code != 0) throw new Error(error.message);

  file.on("stream", (chunk, file) => {
    console.log(chunk.length);
  });

  return file
    .setFileName(params.video) // "avengers.mp4"
    .limitBandwidth(streamConfig.badwidthLimit || 100 /* kb/s */)
    .catch((error) => {
      console.log(error);
      file.close(404, "not found!");
    })
    .send();
});

Streamer.listen(3000, (error) => {
  if (error) throw new Error(error.message);
  console.log("Server is listening on port 3000");
});
```

## Express.JS

```js
const { Streamer } = require("light-streamer");
const express = require("express");
const app = express();

app.use(
  Streamer.expressMiddleware({
    streamBy: "headers",
    badwidthLimit: 300,
    resourceURI: __dirname + "/videos",
    router: {
      endpoints: ["/stream/:video"],
      callback: (error, file, streamConfig, params) => {
        if (error.code != 0) throw new Error(error.message);

        return file
          .setFileName(params.video) // "avengers.mp4"
          .limitBandwidth(streamConfig.badwidthLimit || 100 /* kb/s */)
          .catch((error) => {
            console.log(error);
            file.close(404, "not found!");
          })
          .send();
      },
    },
  })
);

app.listen(3000);
```

## License

light-streamer is freely distributable under the terms of the [MIT license][license-url].

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