Simple static server using express static middle-ware
npm install vp-static-server -g
npm install vp-static-server --save
git clone https://github.com/victor-perez/vp-static-server.git
vp-static-server [options]
or
vpss [options]
node bin/server [options]
this works only by npm > 2
npm run server -- [options]
will always run node bin/server -c ./vp-static-server.json
npm start
var server = require('vp-static-server'),
options = {},
app = server(options); //returns Express application
-r --root Document root to use [./]
-a --host Address to use [0.0.0.0]
-p --port Port to use [0] ( auto select )
-o --open Open server URL in your default browser [true]
-s --https Create a ssl server ( HTTPS ) [false]
--https-cert CERT file for ssl server [ssl/127.0.0.1.cert]
--https-key KEY file for ssl server [ssl/127.0.0.1.key]
--static-* Express.static options:
--static-dotfiles [ignore]
--static-etag [true]
--static-index [index.html]
--static-lastmodified [true]
--static-maxage [0]
--static-redirect [true]
more info http://expressjs.com/4x/api.html#express.static
-c --config Path to the configuration file
-h --help Print this list and exit.
Name | Type | Default | Description |
---|---|---|---|
root | string | ./ | Document root to use |
host | string | 0.0.0.0 | Address to use |
port | number | 0 | Port to use 0 = auto select |
open | boolean | true | Open server URL in your default browser |
https | boolean|object | false | Create a ssl server ( HTTPS ), if true it will use ssl/127.0.0.1.(cert|key) |
https.cert | string | ssl/127.0.0.1.cert | CERT file for ssl server |
https.key | string | ssl/127.0.0.1.key | KEY file for ssl server |
static | object | {} | Express.static options [http://expressjs.com/4x/api.html#express.static] |
{
"root": "./",
"static": {
"dotfiles": "ignore",
"etag": true,
"index": "index.html",
"lastModified": true,
"maxAge": 0,
"redirect": true
},
"host": "0.0.0.0",
"port": 3000,
"open": true,
"https": false
}
Name | Type | Default | Description |
---|---|---|---|
root | string | ./ | Document root to use |
host | string | 0.0.0.0 | Address to use |
port | number | 0 | Port to use 0 = auto select |
open | boolean | true | Open server URL in your default browser |
https | boolean|object | false | Create a ssl server ( HTTPS ), if true it will use ssl/127.0.0.1.(cert|key) |
https.cert | string | ssl/127.0.0.1.cert | CERT file for ssl server |
https.key | string | ssl/127.0.0.1.key | KEY file for ssl server |
static | object | {} | Express.static options [http://expressjs.com/4x/api.html#express.static] |
var server = require('vp-static-server'),
options = {
root: "./",
static: {
dotfiles: "ignore",
etag: true,
index: "index.html",
lastModified: true,
maxAge: 0,
redirect: true
},
host: "0.0.0.0",
port: 3000,
open: true,
https: false
},
app = server(options); //returns express application
if you want to add middleware before the static middleware you can set autostart
to false
and call yourself vpStart()
to start the server
var server = require('vp-static-server'),
options = {
root: "./",
static: {
dotfiles: "ignore",
etag: true,
index: "index.html",
lastModified: true,
maxAge: 0,
redirect: true
},
host: "0.0.0.0",
port: 3000,
open: true,
https: false
},
app = server(options, false); //returns express application
.use((req, res, next) = > {
console.log('log');
next();
});
//start the server
app.vpStart();
npm test