Skip to content

Commit

Permalink
Perfected docs for programmatic API
Browse files Browse the repository at this point in the history
  • Loading branch information
leo authored Feb 19, 2017
1 parent 3aab1b2 commit 20071f5
Showing 1 changed file with 10 additions and 43 deletions.
53 changes: 10 additions & 43 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,60 +38,27 @@ If you set the `--auth` flag, the package will look for a username and password

## API

Install it (needs at least Node LTS):
You can also use the package inside your application. Just load it:

```bash
npm install serve
```js
const serve = require('serve')
```

You can now use it in your code:
And call it with flags (run [this command](#options) for the full list):

```js
const serve = require('serve')

const options = {
const server = serve({
port: 1337,
cache: 0
}

const server = serve(options)
ignore: ['node_modules']
})
```

// ...
Later in the code, you can stop the server using this method:

```js
server.stop()

```

### Options

#### `port: number`

Port to listen on

#### `cache: number`

Time in milliseconds for caching files in the browser

#### `single: boolean`

Serve single page apps with only one `index.html`

#### `unzipped: boolean`

Disable GZIP compression

#### `ignore: string[]`

Files and directories to ignore

#### `auth: boolean`

Serve behind basic auth

#### `cors: boolean`

Setup * CORS headers to allow requests from any origin

## Contributing

1. [Fork](https://help.github.com/articles/fork-a-repo/) this repository to your own GitHub account and then [clone](https://help.github.com/articles/cloning-a-repository/) it to your local device
Expand Down

0 comments on commit 20071f5

Please sign in to comment.