sb-static
v1.0.1
Published
Static file handler for Sebas project.
Downloads
2
Readme
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)