Static Server for NodeJS
Available features
- No npm-dependencies;
- HTTP-methods:
GET
,HEAD
,OPTIONS
; - CORS;
- Support simple cache with
If-Modified-Since
header - Set any directory as public
- Set any file as index-file for server and for subdirectories of public directory
- Simple requests-log to console
- Ready to run out of box
CLI Run
node ./bin/nodess
or with npm
npm start
CLI Parameters & Options
--help
- show help information about cli-configuration.--port
or-p
- port for listening. Default is3000
--public
or-d
- public directory. Default is./public
--cors
- CORS support. Default isfalse
--cache-headers
- support simple cache withIf-Modified-Since
header. Default isfalse
.--index-file
- name of custom index-file. Default isindex.html
.--verbose
- print request-log to console. Default isfalse
.
Examples
const createStaticServer = ;const path = ;const PORT = processenvNODESS_PORT || 3000; let staticServer = ;
For examples, please, see ./examples/*
or tests ./test/*
.
Tests
Tests require Mocha.
mocha ./tests
or with npm
npm test
Test coverage with Istanbul
npm run coverage
Road map
- extended cache-headers support
- gzip support
- support multipart/*
- create npm-package
License
Licensed under the MIT License