Skip to content

Commit

Permalink
docs(Server): add new features
Browse files Browse the repository at this point in the history
  • Loading branch information
hans00 committed Jul 3, 2022
1 parent b8d9298 commit 46e5383
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 0 deletions.
13 changes: 13 additions & 0 deletions docs/Response.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,19 @@ cache_control = false // Turn off Cache-Control

> Redirect, default 302
## `writeHead([status_code = 200, headers = {}])`

> Start write header.
> Default value is internal status
```js
res.status(404).setHeader('TEST', 'CONTENT').writeHead()
```

## `write(data[, callback])`

> Write body data. For (SSE)[https://developer.mozilla.org/docs/Web/API/Server-sent_events/Using_server-sent_events] or stream write.
## `end([data = '', content_type = null])`

> End response, content type default `null`.
Expand Down
23 changes: 23 additions & 0 deletions docs/Server.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
const fastWS = require('fast-ws-server')
const app = new fastWS({...options})

app.setParam()

app.any('/*', (req, res) => {
res.end('')
})
Expand Down Expand Up @@ -102,6 +104,27 @@ app.get('/*', (req, res) => {
})
```

## App params

- `setParam(key, value)`
- `getParam(key)`

> Some options will store in params
```js
const { maxBodySize } = require('fast-ws-server/constants')

app.setParam(maxBodySize, 1024) // int number in bytes
```

### Defined Consts

- `maxBodySize`
- `cache`
- `templateEngine`
- `trustProxy`
- Default: `loopback`

## Serve static file

```js
Expand Down

0 comments on commit 46e5383

Please sign in to comment.