@codebucket/puppet-master 1.0.4 → 1.0.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAQA,KAAK,IAAI,GAAG;IACR,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,MAAM,CAAC;CAClB,CAAA;AAED,KAAK,aAAa,GAAG;IACjB,aAAc,CAAC,EAAE,GAAG,CAAC;IACrB,WAAY,CAAC,EAAE,GAAG,CAAC;IACnB,UAAW,CAAC,EAAE,GAAG,CAAC;IAClB,kBAAmB,CAAC,EAAE,GAAG,CAAC;IAC1B,OAAO,EAAG,MAAM,CAAC;IACjB,OAAO,EAAE,MAAM,CAAC;CACnB,CAAA;AAED,qBAAa,YAAY;IACrB,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAQ;gBAElB,IAAI,EAAE,IAAI;IAShB,GAAG,CAAC,IAAI,EAAE,aAAa;CAchC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAQA,KAAK,IAAI,GAAG;IACR,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,MAAM,CAAC;CAClB,CAAA;AAED,KAAK,aAAa,GAAG;IACjB,aAAc,CAAC,EAAE,GAAG,CAAC;IACrB,WAAY,CAAC,EAAE,GAAG,CAAC;IACnB,UAAW,CAAC,EAAE,GAAG,CAAC;IAClB,kBAAmB,CAAC,EAAE,GAAG,CAAC;IAC1B,OAAO,EAAG,MAAM,CAAC;IACjB,OAAO,EAAE,MAAM,CAAC;CACnB,CAAA;AAED,qBAAa,YAAY;IACrB,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAQ;gBAElB,IAAI,EAAE,IAAI;IAShB,GAAG,CAAC,IAAI,EAAE,aAAa;CAqBhC"}
package/dist/index.js CHANGED
@@ -50,8 +50,15 @@ class PuppetMaster {
50
50
  }
51
51
  catch (err) {
52
52
  if (err instanceof axios_1.AxiosError) {
53
- console.log(err.response?.data);
54
- throw new Error(err.response?.data?.message);
53
+ let streamString = '';
54
+ err.response?.data.setEncoding('utf8');
55
+ err.response?.data
56
+ .on('data', (utf8Chunk) => { streamString += utf8Chunk; })
57
+ .on('end', () => {
58
+ let data = JSON.parse(streamString);
59
+ console.log(data);
60
+ throw new Error(data.message);
61
+ });
55
62
  }
56
63
  throw err;
57
64
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@codebucket/puppet-master",
3
- "version": "1.0.4",
3
+ "version": "1.0.5",
4
4
  "main": "dist/index",
5
5
  "types": "dist/index",
6
6
  "scripts": {
package/src/index.ts CHANGED
@@ -35,13 +35,20 @@ export class PuppetMaster {
35
35
  async pdf(opts: puppeteerOpts) {
36
36
  try {
37
37
  const request = await this.axios.post("/pdf", {task:opts}, {
38
- responseType: "stream"
38
+ responseType: "stream"
39
39
  });
40
40
  await pipeline(request.data, fs.createWriteStream(opts.pdfPath));
41
41
  } catch (err) {
42
42
  if (err instanceof AxiosError) {
43
- console.log(err.response?.data);
44
- throw new Error(err.response?.data?.message);
43
+ let streamString = ''
44
+ err.response?.data.setEncoding('utf8')
45
+ err.response?.data
46
+ .on('data', (utf8Chunk: string) => { streamString += utf8Chunk })
47
+ .on('end', () => {
48
+ let data = JSON.parse(streamString);
49
+ console.log(data);
50
+ throw new Error(data.message);
51
+ })
45
52
  }
46
53
  throw err;
47
54
  }