b-gsdk 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
package/bin/worker.js DELETED
@@ -1,35 +0,0 @@
1
- #!/usr/bin/env node
2
-
3
- const fetch = require('node-fetch')
4
- const shared = require('./shared')
5
- const chunks = []
6
-
7
- process.stdin.resume()
8
- process.stdin.setEncoding('utf8')
9
-
10
- process.stdin.on('data', function (chunk) {
11
- chunks.push(chunk)
12
- })
13
-
14
- process.stdin.on('end', function () {
15
- const input = JSON.parse(chunks.join(''))
16
- const request = shared.deserializeRequest(fetch, ...input)
17
-
18
- fetch(request)
19
- .then(response => response.buffer()
20
- .then(buffer => respond([
21
- buffer.toString('base64'),
22
- shared.serializeResponse(response)
23
- ]))
24
- .catch(error => respond([
25
- '',
26
- shared.serializeResponse(response),
27
- shared.serializeError(error)
28
- ]))
29
- )
30
- .catch(error => respond(shared.serializeError(error)))
31
- })
32
-
33
- function respond (message) {
34
- console.log(JSON.stringify(message))
35
- }