Skip to content

Commit 57184c0

Browse files
committed
Update API.md
Stress that server.expose(obj) is a deep clone and why you might not want that.
1 parent 98a332a commit 57184c0

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

API.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1032,7 +1032,7 @@ exports.register = function (server, options, next) {
10321032

10331033
### `server.expose(obj)`
10341034

1035-
Merges a deep copy of an object into to the existing content of `server.plugins[name]` where:
1035+
Merges an object into to the existing content of `server.plugins[name]` where:
10361036
- `obj` - the object merged into the exposed properties container.
10371037

10381038
```js
@@ -1043,6 +1043,8 @@ exports.register = function (server, options, next) {
10431043
};
10441044
```
10451045

1046+
Note that all properties of `obj` are deeply cloned into `server.plugins[name]`, so you should avoid using this method for exposing large objects that may be expensive to clone or singleton objects such as database client objects. Instead favor the `server.expose(key, value)` form, which only copies a reference to `value`.
1047+
10461048
### `server.ext(events)`
10471049

10481050
Registers an extension function in one of the available extension points where:

0 commit comments

Comments
 (0)