Skip to content

Commit

Permalink
Creating parser() & updating README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
avoidwork committed Jan 4, 2021
1 parent 453af4b commit 80868cf
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 3 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,10 @@ Tenso 1.4.0 added a few common format renderers, such as CSV, HTML, YAML, & XML.

Custom renderers can be registered with `server.renderer('mimetype', fn);` or directly on `server.renderers`. The parameters for a renderer are `(req, res, arg)`. Custom serializes can be registered with `server.serializer('mimetype', fn);` or directly on `server.serializers`. The parameters for a serializer are `(arg, err, status = 200, stack = false)`; if `arg` is `null` then `err` must be an `Error` & `stack` determines if the response body is the `Error.message` or `Error.stack` property.

## Parsers

Custom renderers can be registered with `server.parser('mimetype', fn);` or directly on `server.parsers`. The parameters for a renderer are `(arg)`.

## Configuration
This is a sample configuration for Tenso, without authentication or SSL. This would be ideal for development, but not production! Enabling SSL is as easy as providing file paths for the two keys.

Expand Down
6 changes: 6 additions & 0 deletions lib/tenso.js
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,12 @@ class Tenso extends Base {
return this;
}

parser (mimetype, fn) {
this.parsers.set(mimetype, fn);

return this;
}

rate (req, fn) {
const config = this.config.rate,
id = req.sessionID || req.ip;
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "tenso",
"description": "Tenso is an HTTP REST API framework",
"version": "16.0.6",
"version": "16.0.7",
"homepage": "https://github.com/avoidwork/tenso",
"author": "Jason Mulligan <[email protected]>",
"repository": {
Expand Down

0 comments on commit 80868cf

Please sign in to comment.