@ceicc/range
Advanced tools
Comparing version 3.0.0-beta.8 to 3.0.0-no-types-dir
{ | ||
"name": "@ceicc/range", | ||
"version": "3.0.0-beta.8", | ||
"version": "3.0.0-no-types-dir", | ||
"description": "http range request handler", | ||
@@ -33,3 +33,2 @@ "exports": "./lib/index.js", | ||
"lib/", | ||
"types/", | ||
"README.md", | ||
@@ -39,3 +38,2 @@ "LICENSE", | ||
], | ||
"types": "types/", | ||
"engines": { | ||
@@ -42,0 +40,0 @@ "node": ">=14.16" |
@@ -1,8 +0,11 @@ | ||
# range | ||
A static files middleware | ||
# Range | ||
Middleware for serving static files | ||
[](https://npmjs.com/package/@ceicc/range) | ||
[](https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c) | ||
## Installation | ||
```bash | ||
npm i @ceicc/range | ||
``` | ||
npm i @ceicc/range@next | ||
``` | ||
@@ -14,7 +17,4 @@ ## Usage | ||
```js | ||
import range from "@ceicc/range" | ||
import { range } from "@ceicc/range" | ||
// CommonJS | ||
// const range = require("@ceicc/range") | ||
app.get('/public/*', range()) | ||
@@ -131,3 +131,3 @@ | ||
the compression method will be determined based on the request's `accept-encoding` header using npm package `negotiator`. | ||
the compression method will be determined based on the request's [`accept-encoding`](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/accept-encoding) header using npm package [`negotiator`](https://npmjs.com/package/negotiator). | ||
@@ -147,9 +147,13 @@ #### `dateHeader` | ||
```js | ||
import { fileURLToPath } from "node:url" | ||
import { join, dirname } from "node:path" | ||
import express from "express" | ||
import range from "@ceicc/range" | ||
import { range } from "@ceicc/range" | ||
const app = express() | ||
app.get('*', range({ baseDir: './public/' })) | ||
const __dirname = dirname(fileURLToPath(import.meta.url)) | ||
app.get('*', range({ baseDir: join(__dirname, "public") })) | ||
app.use((error, req, res, next) => { | ||
@@ -160,3 +164,3 @@ console.error(error) | ||
app.listen(80, () => console.log("server listening on localhost")) | ||
app.listen(3000, () => console.log("server listening on http://localhost:3000")) | ||
``` |
17737
162