1.0.4 • Published 1 year ago

@nanoexpress/middleware-static-serve v1.0.4

Weekly downloads
4
License
MIT
Repository
github
Last release
1 year ago

static

Static file serve middleware for nanoexpress

Installation

npm i @nanoexpress/middleware-static-serve
# or
yarn add @nanoexpress/middleware-static-serve

Example

See the examples directory

Usage

ESM Module

import staticServe from '@nanoexpress/middleware-static-serve';

app.use(staticServe('./static'));

CJS Module

const staticServe = require('@nanoexpress/middleware-static-serve/cjs');

app.use(staticServe('./static'));

Arguments

NameTypeDescription
pathStringPath of your static serve folder
optionsObjectSee Options

Options

Options nameDefaultRequiredDescription
options.modecachedNoServe mode*, has two values - Cached and Live
options.indexindex.htmlNoIndex filename
options.forcePrettyfalseNoForce appending index-file path
options.addPrettyUrltrueNoEnable pretty url by auto-appending index-file
options.lastModifiedtrueNoEnable browsers Last-modified check
options.compressedtrueNoCompress response/response streams

* - Cached gives better performance, but on refresh gives cached result and uses more RAM. Live mode uses less memory usage, on request responses last version but on high-load applicatins may reduces performance

License

MIT