0.1.1 • Published 9 years ago
static-server-nodejs v0.1.1
Static Server for NodeJS
Available features
- No npm-dependencies;
- HTTP-methods:
GET,HEAD,OPTIONS; - CORS;
- Support simple cache with
If-Modified-Sinceheader - 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/nodessor with npm
npm startCLI Parameters & Options
--help- show help information about cli-configuration.--portor-p- port for listening. Default is3000--publicor-d- public directory. Default is./public--cors- CORS support. Default isfalse--cache-headers- support simple cache withIf-Modified-Sinceheader. Default isfalse.--index-file- name of custom index-file. Default isindex.html.--verbose- print request-log to console. Default isfalse.
Examples
const createStaticServer = require('static-server-nodejs');
const path = require('path');
const PORT = process.env.NODESS_PORT || 3000;
let staticServer = createStaticServer(path.join(__dirname, './public'),{
cors: true,
cache: true,
indexFile: 'index.html',
verbose: true
})
.listen(PORT, '127.0.0.1', () => {
console.log(`Server run and listen on ${PORT} port.`);
});For examples, please, see ./examples/* or tests ./test/*.
Tests
Tests require Mocha.
mocha ./testsor with npm
npm test Test coverage with Istanbul
npm run coverageRoad map
- extended cache-headers support
- gzip support
- support multipart/*
- create npm-package
License
Licensed under the MIT License