# vp-static-server

> Simple static server using express static middleware works both on HTTP and HTTPS

Latest version **1.0.4** (published 2019-01-31) · Apache-2.0 license · 0 weekly downloads

> **Deprecated.** This package is deprecated.

## Install

```sh
npm install vp-static-server
pnpm add vp-static-server
yarn add vp-static-server
bun add vp-static-server
```

Provides the commands `vpss`, `vp-static-server`.

## Health

**Score 10/100 (F)** — status: deprecated.

Negative: deprecated.

## Facts

| | |
|---|---|
| Version | 1.0.4 |
| Published | 2019-01-31 |
| First published | 2015-07-21 |
| Weekly downloads | 0 |
| License | Apache-2.0 |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 5 |
| Unpacked size | 39.3 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 2 |
| Author | V.A. Perez |
| Maintainers | victor-perez |
| Keywords | static, server, express, simple, http, https, assets, local, tool, serve |

## Links

- npm: https://www.npmjs.com/package/vp-static-server
- Repository: https://github.com/victor-perez/vp-static-server
- Issues: https://github.com/victor-perez/vp-static-server/issues
- npm.io page: https://npm.io/package/vp-static-server

## Dependencies (5)

- [opn](https://npm.io/package/opn.md) ^5.4.0
- [colors](https://npm.io/package/colors.md) ^1.1.2
- [express](https://npm.io/package/express.md) ^4.13.1
- [minimist](https://npm.io/package/minimist.md) ^1.1.1
- [underscore](https://npm.io/package/underscore.md) ^1.8.3

## Alternatives

- [lodash.assign](https://npm.io/package/lodash.assign.md) — 2.3M weekly downloads
- [lodash.chunk](https://npm.io/package/lodash.chunk.md) — 1.8M weekly downloads
- [react-native-ios-utilities](https://npm.io/package/react-native-ios-utilities.md) — 138.5K weekly downloads
- [@technically/lodash](https://npm.io/package/@technically/lodash.md) — 50.9K weekly downloads
- [@fluid-topics/ft-icon](https://npm.io/package/@fluid-topics/ft-icon.md) — 20.6K weekly downloads

## Recent versions

- 1.0.4 (latest) — 2019-01-31
- 1.0.2 — 2017-01-25
- 1.0.1 — 2017-01-24
- 1.0.0 — 2015-07-30
- 0.0.5 — 2015-07-28
- 0.0.4 — 2015-07-27
- 0.0.3 — 2015-07-23
- 0.0.2 — 2015-07-21
- 0.0.1 — 2015-07-21

## README

[![Dependency Status](https://david-dm.org/victor-perez/vp-static-server.svg)](https://david-dm.org/victor-perez/vp-static-server)
[![devDependency Status](https://david-dm.org/victor-perez/vp-static-server/dev-status.svg)](https://david-dm.org/victor-perez/vp-static-server#info=devDependencies)

[![NPM](https://nodei.co/npm/vp-static-server.png?downloads=true&downloadRank=true&stars=true)](https://nodei.co/npm/vp-static-server/)

vp-static-server
======
Simple static server using express static middle-ware

## Getting Started

### Install

#### Global
`npm install vp-static-server -g`

#### Project dependency
`npm install vp-static-server --save`

#### GIT
`git clone https://github.com/victor-perez/vp-static-server.git`

## Usage

### global
`vp-static-server [options]`

or

`vpss [options]`

### node
`node bin/server [options]`

### npm run
this works only by npm > 2

`npm run server -- [options]`

### npm start
will always run `node bin/server -c ./vp-static-server.json`

`npm start`

### scripting
```javascript
var server = require('vp-static-server'),
    options = {},
    app = server(options); //returns Express application
```

## Options

### cli, node & npm run
```
-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.                                  
```

### config.json
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]

#### example
```json
{
    "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
}
```
### scripting

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]

#### example
```javascript
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
```

#### example delay start
if you want to add middleware before the static middleware you can set `autostart` to `false` and call yourself `vpStart()` to start the server

```javascript
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();
```


## Testing
`npm test`

---
_Source: https://npm.io/package/vp-static-server · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
