Skip to content

Commit 9d49eba

Browse files
author
Amoki
committed
Merge branch 'master' of github.com:Papiel/anyfetch-file-hydrater.js
2 parents 6bc6d3a + c653ab8 commit 9d49eba

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

README.md

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,15 @@ This library allows you to create a hydrater server from a single function. Taki
1010

1111
Read first
1212
----------
13-
To better understand the role of "hydraters", read the [dedicated documentation page](http://developers.anyfetch.com/guides/using/hydrater.html).
13+
To understand the role of "hydraters", read the [dedicated documentation page](http://developers.anyfetch.com/guides/using/hydrater.html).
1414

1515
Usage
1616
-----
1717

18+
In `path/to/my/function.js`:
1819
```js
1920
'use strict';
2021

21-
var anyfetchHydrater = require('anyfetch-hydrater');
22-
2322
/**
2423
* Hydration function, to add metadata to the document
2524
*
@@ -28,15 +27,22 @@ var anyfetchHydrater = require('anyfetch-hydrater');
2827
* @param {Object} changes Convenience object provided with empty keys `document_type`, `metadata`, `data` and `actions`. Add your changes in there.
2928
* @param {Function} cb(err, changes) Call this with an error if any, or pass your changes as second parameter.
3029
*/
31-
var myHydrationFunction = function(path, document, changes, cb)
30+
module.exports = function myHydrationFunction(path, document, changes, cb)
3231
// Extract interesting stuff from the file or the document...
3332
// Improve the document...
3433

3534
cb(err, changes);
3635
};
36+
```
37+
38+
And then:
39+
```js
40+
'use strict';
41+
42+
var anyfetchHydrater = require('anyfetch-hydrater');
3743

3844
var config = {
39-
'hydrater_function': myHydrationFunction
45+
'hydrater_function': 'path/to/my/function.js'
4046
};
4147

4248
var hydrationServer = anyfetchHydrater.createServer(config);
@@ -80,4 +86,3 @@ For other (transient) errors, use standard `Error` objects.
8086

8187
### Optional env variables
8288
* `TIMEOUT` in ms. Time to hydrate a file. After this, the process will stop the file hydration and the next file will be hydrated. Default: 60 sec.
83-
WARNING: If you use childProcess to spawn something, this something won't be killed. Put an inferior timeout manually on this something

0 commit comments

Comments
 (0)