# @bayerjs/middleware

> Middleware for the Bayer.js server library

Latest version **0.2.0-alpha.0** (published 2018-12-26) · MIT license · 0 weekly downloads

## Install

```sh
npm install @bayerjs/middleware
pnpm add @bayerjs/middleware
yarn add @bayerjs/middleware
bun add @bayerjs/middleware
```

## 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.2.0-alpha.0 |
| Published | 2018-12-26 |
| First published | 2018-11-25 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 13.3 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Nathan Graule |
| Maintainers | solarliner |
| Keywords | bayerjs, middleware |

## Links

- npm: https://www.npmjs.com/package/@bayerjs/middleware
- Repository: https://github.com/SolarLiner/bayer-js
- Homepage: https://github.com/SolarLiner/bayer-js#readme
- Issues: https://github.com/SolarLiner/bayer-js/issues
- npm.io page: https://npm.io/package/@bayerjs/middleware

## Dependencies (1)

- [@bayerjs/core](https://npm.io/package/@bayerjs/core.md) ^0.2.0-alpha.0

## Alternatives

- [@sindresorhus/slugify](https://npm.io/package/@sindresorhus/slugify.md) — 3.7M weekly downloads
- [solid-js](https://npm.io/package/solid-js.md) — 2.7M weekly downloads
- [expo-glass-effect](https://npm.io/package/expo-glass-effect.md) — 2.5M weekly downloads
- [nanoassert](https://npm.io/package/nanoassert.md) — 780.8K weekly downloads
- [@ffmpeg/ffmpeg](https://npm.io/package/@ffmpeg/ffmpeg.md) — 529.5K weekly downloads

## Recent versions

- 0.2.0-alpha.0 (latest) — 2018-12-26
- 0.0.2-alpha.0 — 2018-11-25
- 0.0.1-alpha.0 — 2018-11-25

## README

# `@bayerjs/middleware`

Middleware functions to be used with the Bayer.js server library.

## Static files

Handle static files simply by plugging the `staticFiles` middleware into your server.

```typescript
import { staticFiles } from "@bayerjs/middleware";

// Will serve the "public" folder that's alongside this script file
app.use(staticFiles(join(__dirname, "public"), "/"))

app.listen();
```

By default, this middleware will check if the route points to a folder, and if it does, try to send the `index.html`
file in that folder if found. To disable this, set `useIndexFile` to false. To change the extension of the index file,
set `indexExtension` to the extension of your choice.

```typescript
app.use(staticFiles(join(__dirname, "public"), "/", /*useIndexFile*/ true, /*indexExtension*/ "json"));
```

The middleware will check whether the file exists and is readable before streaming it to the client. The appropriate
response codes will be used otherwise.

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