diff --git a/docs/Response.md b/docs/Response.md index 3b74c64..cd8ab84 100644 --- a/docs/Response.md +++ b/docs/Response.md @@ -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`. diff --git a/docs/Server.md b/docs/Server.md index 30af4e5..9be536c 100644 --- a/docs/Server.md +++ b/docs/Server.md @@ -6,6 +6,8 @@ const fastWS = require('fast-ws-server') const app = new fastWS({...options}) +app.setParam() + app.any('/*', (req, res) => { res.end('') }) @@ -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