sb-static

1.0.1 • Public • Published

sb-static

Static file handler for Sebas project.

stability

  • experimental

features

current

  • Etag/Last-Modified header support
  • Fallback
  • Caching file chunks (memcached)
  • Chunk integrity check (optional)

todo

  • compression support
  • watch file changes (refresh metadata)

usage

const { servestatic } = require('sb-static')

server.on('request', (request, response) => {
 servestatic(request, response, next, {
  'dir': format('{0}/dist', __dirname),
  'hashedStore': sebas.hashedStore,
  'memchync': memchync,
  'fallBack':  format('{0}/dist/index.html', __dirname)
 })
})

servestatic(request, response, next, options)

options

Required:

  • dir - directory of static files
  • hashedStore - a shared hashed store for hashing the file path and used as keys on memcache

Optional:

  • memchync - use memcached to cache file contents (default=false)
  • cacheControl: cache control headers (max-age:432000)
  • fallBack: If a file is not found fallback to this specific file (default: returns 404 error)
  • noIntegrety: Disable integrety check (default=true)

/sb-static/

    Package Sidebar

    Install

    npm i sb-static

    Weekly Downloads

    0

    Version

    1.0.1

    License

    MIT

    Unpacked Size

    1.52 MB

    Total Files

    32

    Last publish

    Collaborators

    • jp6rt