@donmahallem/turbo 2.3.8 → 2.3.12

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.
package/dist/cjs/index.js CHANGED
@@ -2,86 +2,86 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- /*
6
- * Package @donmahallem/turbo
7
- * Source https://github.com/donmahallem/js-libs/tree/master/packages/turbo
8
- */
9
- /**
10
- * Awaits an promise and returns it
11
- *
12
- * @param prom promise to convert
13
- * @param res the express.Response to use
14
- * @param next (optional) response object
15
- */
16
- const promiseToResponse = (prom, res, next) => {
17
- prom.then((value) => {
18
- (res.headersSent ? res : res.status(200)).json(value);
19
- }).catch((err) => {
20
- var _a;
21
- if (next) {
22
- next(err);
23
- return;
24
- // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
25
- }
26
- else if (err && err.isAxiosError === true) {
27
- // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
28
- const axiosError = err;
29
- const code = ((_a = axiosError.response) === null || _a === void 0 ? void 0 : _a.status) || 500;
30
- res.status(code).json({
31
- error: true,
32
- statusCode: code,
33
- });
34
- return;
35
- }
36
- else {
37
- // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-assignment
38
- const code = (err === null || err === void 0 ? void 0 : err.statusCode) || 500;
39
- res.status(code).json({
40
- error: true,
41
- statusCode: code,
42
- });
43
- return;
44
- }
45
- });
5
+ /*
6
+ * Package @donmahallem/turbo
7
+ * Source https://github.com/donmahallem/js-libs/tree/master/packages/turbo
8
+ */
9
+ /**
10
+ * Awaits an promise and returns it
11
+ *
12
+ * @param prom promise to convert
13
+ * @param res the express.Response to use
14
+ * @param next (optional) response object
15
+ */
16
+ const promiseToResponse = (prom, res, next) => {
17
+ prom.then((value) => {
18
+ (res.headersSent ? res : res.status(200)).json(value);
19
+ }).catch((err) => {
20
+ var _a;
21
+ if (next) {
22
+ next(err);
23
+ return;
24
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
25
+ }
26
+ else if (err && err.isAxiosError === true) {
27
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
28
+ const axiosError = err;
29
+ const code = ((_a = axiosError.response) === null || _a === void 0 ? void 0 : _a.status) || 500;
30
+ res.status(code).json({
31
+ error: true,
32
+ statusCode: code,
33
+ });
34
+ return;
35
+ }
36
+ else {
37
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-assignment
38
+ const code = (err === null || err === void 0 ? void 0 : err.statusCode) || 500;
39
+ res.status(code).json({
40
+ error: true,
41
+ statusCode: code,
42
+ });
43
+ return;
44
+ }
45
+ });
46
46
  };
47
47
 
48
- /*
49
- * Package @donmahallem/turbo
50
- * Source https://github.com/donmahallem/js-libs/tree/master/packages/turbo
51
- */
52
- /**
53
- * Does create an request handler that transforms a provided promise
54
- * into an response
55
- *
56
- * @param prom a promise to handle
57
- */
58
- const promiseRequestHandler = (prom) => (req, res, next) => {
59
- promiseToResponse(prom(req, res), res, next);
48
+ /*
49
+ * Package @donmahallem/turbo
50
+ * Source https://github.com/donmahallem/js-libs/tree/master/packages/turbo
51
+ */
52
+ /**
53
+ * Does create an request handler that transforms a provided promise
54
+ * into an response
55
+ *
56
+ * @param prom a promise to handle
57
+ */
58
+ const promiseRequestHandler = (prom) => (req, res, next) => {
59
+ promiseToResponse(prom(req, res), res, next);
60
60
  };
61
61
 
62
- /*
63
- * Package @donmahallem/turbo
64
- * Source https://github.com/donmahallem/js-libs/tree/master/packages/turbo
65
- */
66
- /**
67
- * Error that should be compatible with express errors
68
- */
69
- class RequestError extends Error {
70
- /**
71
- *
72
- * @param message error message
73
- * @param status status code to be reported
74
- */
75
- constructor(message, status = 500) {
76
- super(message);
77
- this.status = status;
78
- this.name = RequestError.name;
79
- }
62
+ /*
63
+ * Package @donmahallem/turbo
64
+ * Source https://github.com/donmahallem/js-libs/tree/master/packages/turbo
65
+ */
66
+ /**
67
+ * Error that should be compatible with express errors
68
+ */
69
+ class RequestError extends Error {
70
+ /**
71
+ *
72
+ * @param message error message
73
+ * @param status status code to be reported
74
+ */
75
+ constructor(message, status = 500) {
76
+ super(message);
77
+ this.status = status;
78
+ this.name = RequestError.name;
79
+ }
80
80
  }
81
81
 
82
82
  exports.RequestError = RequestError;
83
83
  exports.promiseRequestHandler = promiseRequestHandler;
84
84
  exports.promiseToResponse = promiseToResponse;
85
- // BUILD: Sun Feb 06 2022 11:27:20 GMT+0100 (Central European Standard Time)
85
+ // BUILD: Thu Mar 10 2022 12:32:55 GMT+0000 (Coordinated Universal Time)
86
86
 
87
87
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../../src/promise-to-response.ts","../../src/promise-request-handler.ts","../../src/request-error.ts"],"sourcesContent":[null,null,null],"names":[],"mappings":";;;;AAAA;;;;AAWA;;;;;;;MAOa,iBAAiB,GAAe,CAAI,IAAgB,EAAE,GAAiC,EAAE,IAAmB;IACrH,IAAI,CAAC,IAAI,CAAC,CAAC,KAAQ;QACf,CAAC,GAAG,CAAC,WAAW,GAAG,GAAG,GAAG,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC;KACzD,CAAC,CAAC,KAAK,CAAC,CAAC,GAAqB;;QAC3B,IAAI,IAAI,EAAE;YACN,IAAI,CAAC,GAAG,CAAC,CAAC;YACV,OAAO;;SAEV;aAAM,IAAI,GAAG,IAAI,GAAG,CAAC,YAAY,KAAK,IAAI,EAAE;;YAEzC,MAAM,UAAU,GAAe,GAAG,CAAC;YACnC,MAAM,IAAI,GAAW,CAAA,MAAA,UAAU,CAAC,QAAQ,0CAAE,MAAM,KAAI,GAAG,CAAC;YACxD,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC;gBAClB,KAAK,EAAE,IAAI;gBACX,UAAU,EAAE,IAAI;aACnB,CAAC,CAAC;YACH,OAAO;SACV;aAAM;;YAEH,MAAM,IAAI,GAAW,CAAA,GAAG,aAAH,GAAG,uBAAH,GAAG,CAAE,UAAU,KAAI,GAAG,CAAC;YAC5C,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC;gBAClB,KAAK,EAAE,IAAI;gBACX,UAAU,EAAE,IAAI;aACnB,CAAC,CAAC;YACH,OAAO;SACV;KACJ,CAAC,CAAC;AACP;;AC7CA;;;;AAWA;;;;;;MAMa,qBAAqB,GAC9B,CAAI,IAAwB,KAC5B,CAAC,GAAY,EAAE,GAAiC,EAAE,IAAkB;IAChE,iBAAiB,CAAC,IAAI,CAAC,GAAG,EAAE,GAAG,CAAC,EAAE,GAAG,EAAE,IAAI,CAAC,CAAC;AACjD;;ACrBJ;;;;AAKA;;;MAGa,YAAa,SAAQ,KAAK;;;;;;IAMnC,YAAY,OAAe,EAAkB,SAAiB,GAAG;QAC7D,KAAK,CAAC,OAAO,CAAC,CAAC;QAD0B,WAAM,GAAN,MAAM,CAAc;QAE7D,IAAI,CAAC,IAAI,GAAG,YAAY,CAAC,IAAI,CAAC;KACjC;;;;;;;;"}
1
+ {"version":3,"file":"index.js","sources":["../../src/promise-to-response.ts","../../src/promise-request-handler.ts","../../src/request-error.ts"],"sourcesContent":[null,null,null],"names":[],"mappings":";;;;AAAA,CAAA,CAAA;;;AAGG,CAAA,CAAA,CAAA;AAQH,CAAA,CAAA,CAAA;;;;;;AAMG,CAAA,CAAA,CAAA;AACU,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAiB,GAAe,CAAI,CAAA,CAAA,CAAA,CAAgB,EAAE,CAAiC,CAAA,CAAA,CAAA,CAAE,IAAmB,CAAU,CAAA,CAAA,CAAA,CAAA,CAAA;AAC/H,CAAA,CAAA,CAAA,CAAA,IAAI,CAAC,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CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAK,CAAA,CAAA;AACnC,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA;;;;AAIG,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA;IACH,WAAY,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAe,EAAkB,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAiB,GAAG,CAAA,CAAA,CAAA;QAC7D,CAAK,CAAA,CAAA,CAAA,CAAA,CAAC,CAAO,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAC,CAAC;QAD0B,CAAM,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAN,MAAM,CAAc;AAE7D,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,IAAI,CAAC,CAAA,CAAA,CAAA,CAAI,GAAG,CAAY,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAC,IAAI,CAAC;CACjC,CAAA,CAAA,CAAA,CAAA;AACJ,CAAA;;;;;;;"}
package/dist/esm/index.js CHANGED
@@ -1,81 +1,81 @@
1
- /*
2
- * Package @donmahallem/turbo
3
- * Source https://github.com/donmahallem/js-libs/tree/master/packages/turbo
4
- */
5
- /**
6
- * Awaits an promise and returns it
7
- *
8
- * @param prom promise to convert
9
- * @param res the express.Response to use
10
- * @param next (optional) response object
11
- */
12
- const promiseToResponse = (prom, res, next) => {
13
- prom.then((value) => {
14
- (res.headersSent ? res : res.status(200)).json(value);
15
- }).catch((err) => {
16
- var _a;
17
- if (next) {
18
- next(err);
19
- return;
20
- // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
21
- }
22
- else if (err && err.isAxiosError === true) {
23
- // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
24
- const axiosError = err;
25
- const code = ((_a = axiosError.response) === null || _a === void 0 ? void 0 : _a.status) || 500;
26
- res.status(code).json({
27
- error: true,
28
- statusCode: code,
29
- });
30
- return;
31
- }
32
- else {
33
- // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-assignment
34
- const code = (err === null || err === void 0 ? void 0 : err.statusCode) || 500;
35
- res.status(code).json({
36
- error: true,
37
- statusCode: code,
38
- });
39
- return;
40
- }
41
- });
1
+ /*
2
+ * Package @donmahallem/turbo
3
+ * Source https://github.com/donmahallem/js-libs/tree/master/packages/turbo
4
+ */
5
+ /**
6
+ * Awaits an promise and returns it
7
+ *
8
+ * @param prom promise to convert
9
+ * @param res the express.Response to use
10
+ * @param next (optional) response object
11
+ */
12
+ const promiseToResponse = (prom, res, next) => {
13
+ prom.then((value) => {
14
+ (res.headersSent ? res : res.status(200)).json(value);
15
+ }).catch((err) => {
16
+ var _a;
17
+ if (next) {
18
+ next(err);
19
+ return;
20
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
21
+ }
22
+ else if (err && err.isAxiosError === true) {
23
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
24
+ const axiosError = err;
25
+ const code = ((_a = axiosError.response) === null || _a === void 0 ? void 0 : _a.status) || 500;
26
+ res.status(code).json({
27
+ error: true,
28
+ statusCode: code,
29
+ });
30
+ return;
31
+ }
32
+ else {
33
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-assignment
34
+ const code = (err === null || err === void 0 ? void 0 : err.statusCode) || 500;
35
+ res.status(code).json({
36
+ error: true,
37
+ statusCode: code,
38
+ });
39
+ return;
40
+ }
41
+ });
42
42
  };
43
43
 
44
- /*
45
- * Package @donmahallem/turbo
46
- * Source https://github.com/donmahallem/js-libs/tree/master/packages/turbo
47
- */
48
- /**
49
- * Does create an request handler that transforms a provided promise
50
- * into an response
51
- *
52
- * @param prom a promise to handle
53
- */
54
- const promiseRequestHandler = (prom) => (req, res, next) => {
55
- promiseToResponse(prom(req, res), res, next);
44
+ /*
45
+ * Package @donmahallem/turbo
46
+ * Source https://github.com/donmahallem/js-libs/tree/master/packages/turbo
47
+ */
48
+ /**
49
+ * Does create an request handler that transforms a provided promise
50
+ * into an response
51
+ *
52
+ * @param prom a promise to handle
53
+ */
54
+ const promiseRequestHandler = (prom) => (req, res, next) => {
55
+ promiseToResponse(prom(req, res), res, next);
56
56
  };
57
57
 
58
- /*
59
- * Package @donmahallem/turbo
60
- * Source https://github.com/donmahallem/js-libs/tree/master/packages/turbo
61
- */
62
- /**
63
- * Error that should be compatible with express errors
64
- */
65
- class RequestError extends Error {
66
- /**
67
- *
68
- * @param message error message
69
- * @param status status code to be reported
70
- */
71
- constructor(message, status = 500) {
72
- super(message);
73
- this.status = status;
74
- this.name = RequestError.name;
75
- }
58
+ /*
59
+ * Package @donmahallem/turbo
60
+ * Source https://github.com/donmahallem/js-libs/tree/master/packages/turbo
61
+ */
62
+ /**
63
+ * Error that should be compatible with express errors
64
+ */
65
+ class RequestError extends Error {
66
+ /**
67
+ *
68
+ * @param message error message
69
+ * @param status status code to be reported
70
+ */
71
+ constructor(message, status = 500) {
72
+ super(message);
73
+ this.status = status;
74
+ this.name = RequestError.name;
75
+ }
76
76
  }
77
77
 
78
78
  export { RequestError, promiseRequestHandler, promiseToResponse };
79
- // BUILD: Sun Feb 06 2022 11:27:20 GMT+0100 (Central European Standard Time)
79
+ // BUILD: Thu Mar 10 2022 12:32:55 GMT+0000 (Coordinated Universal Time)
80
80
 
81
81
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../../src/promise-to-response.ts","../../src/promise-request-handler.ts","../../src/request-error.ts"],"sourcesContent":[null,null,null],"names":[],"mappings":"AAAA;;;;AAWA;;;;;;;MAOa,iBAAiB,GAAe,CAAI,IAAgB,EAAE,GAAiC,EAAE,IAAmB;IACrH,IAAI,CAAC,IAAI,CAAC,CAAC,KAAQ;QACf,CAAC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C,IAAI,CAAC;KACjC;;;;;;"}
1
+ {"version":3,"file":"index.js","sources":["../../src/promise-to-response.ts","../../src/promise-request-handler.ts","../../src/request-error.ts"],"sourcesContent":[null,null,null],"names":[],"mappings":"AAAA,CAAA,CAAA;;;AAGG,CAAA,CAAA,CAAA;AAQH,CAAA,CAAA,CAAA;;;;;;AAMG,CAAA,CAAA,CAAA;AACU,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAiB,GAAe,CAAI,CAAA,CAAA,CAAA,CAAgB,EAAE,CAAiC,CAAA,CAAA,CAAA,CAAE,IAAmB,CAAU,CAAA,CAAA,CAAA,CAAA,CAAA;AAC/H,CAAA,CAAA,CAAA,CAAA,IAAI,CAAC,CAAA,CAAA,CAAA,CAAI,CAAC,CAAC,KAAQ,CAAU,CAAA,CAAA,CAAA,CAAA,CAAA;QACzB,CAAC,CAAG,CAAA,CAAA,CAAC,WAAW,CAAG,CAAA,CAAA,CAAA,CAAA,CAAG,GAAG,CAAG,CAAA,CAAA,CAAC,CAAM,CAAA,CAAA,CAAA,CAAA,CAAA,CAAC,GAAG,CAAC,CAAA,CAAE,IAAI,CAAC,CAAA,CAAA,CAAA,CAAA,CAAK,CAAC,CAAC;AAC1D,CAAA,CAAA,CAAA,CAAA,CAAC,CAAC,CAAC,CAAA,CAAA,CAAA,CAAA,CAAK,CAAC,CAAC,GAAqB,CAAU,CAAA,CAAA,CAAA,CAAA,CAAA;;AACrC,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAI,IAAI,CAAE,CAAA,CAAA;YACN,CAAI,CAAA,CAAA,CAAA,CAAC,CAAG,CAAA,CAAA,CAAC,CAAC;YACV,CAAO,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA;;AAEV,CAAA,CAAA,CAAA,CAAA,C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AA,CAAC,IAAI,CAAC;CACjC,CAAA,CAAA,CAAA,CAAA;AACJ,CAAA;;;;;"}
@@ -1,11 +1,11 @@
1
- /**
2
- * Error Object to provide
3
- */
4
- export interface IErrorResponse {
5
- error: true;
6
- /**
7
- * Http Status Code
8
- */
9
- statusCode: number;
10
- }
1
+ /**
2
+ * Error Object to provide
3
+ */
4
+ export interface IErrorResponse {
5
+ error: true;
6
+ /**
7
+ * Http Status Code
8
+ */
9
+ statusCode: number;
10
+ }
11
11
  //# sourceMappingURL=error-response.d.ts.map
@@ -1,4 +1,4 @@
1
- export { promiseRequestHandler } from './promise-request-handler';
2
- export { promiseToResponse } from './promise-to-response';
3
- export { RequestError } from './request-error';
1
+ export { promiseRequestHandler } from './promise-request-handler';
2
+ export { promiseToResponse } from './promise-to-response';
3
+ export { RequestError } from './request-error';
4
4
  //# sourceMappingURL=index.d.ts.map
@@ -1,11 +1,11 @@
1
- import type { Request, RequestHandler, Response } from 'express';
2
- declare type MethodInterface<T> = (req?: Request, res?: Response<T>) => Promise<T>;
3
- /**
4
- * Does create an request handler that transforms a provided promise
5
- * into an response
6
- *
7
- * @param prom a promise to handle
8
- */
9
- export declare const promiseRequestHandler: <T>(prom: MethodInterface<T>) => RequestHandler;
10
- export {};
1
+ import type { Request, RequestHandler, Response } from 'express';
2
+ declare type MethodInterface<T> = (req?: Request, res?: Response<T>) => Promise<T>;
3
+ /**
4
+ * Does create an request handler that transforms a provided promise
5
+ * into an response
6
+ *
7
+ * @param prom a promise to handle
8
+ */
9
+ export declare const promiseRequestHandler: <T>(prom: MethodInterface<T>) => RequestHandler;
10
+ export {};
11
11
  //# sourceMappingURL=promise-request-handler.d.ts.map
@@ -1,12 +1,12 @@
1
- import type { NextFunction, Response } from 'express';
2
- declare type MethodType = <T>(prom: Promise<T>, res: Response, next?: NextFunction) => void;
3
- /**
4
- * Awaits an promise and returns it
5
- *
6
- * @param prom promise to convert
7
- * @param res the express.Response to use
8
- * @param next (optional) response object
9
- */
10
- export declare const promiseToResponse: MethodType;
11
- export {};
1
+ import type { NextFunction, Response } from 'express';
2
+ declare type MethodType = <T>(prom: Promise<T>, res: Response, next?: NextFunction) => void;
3
+ /**
4
+ * Awaits an promise and returns it
5
+ *
6
+ * @param prom promise to convert
7
+ * @param res the express.Response to use
8
+ * @param next (optional) response object
9
+ */
10
+ export declare const promiseToResponse: MethodType;
11
+ export {};
12
12
  //# sourceMappingURL=promise-to-response.d.ts.map
@@ -1,13 +1,13 @@
1
- /**
2
- * Error that should be compatible with express errors
3
- */
4
- export declare class RequestError extends Error {
5
- readonly status: number;
6
- /**
7
- *
8
- * @param message error message
9
- * @param status status code to be reported
10
- */
11
- constructor(message: string, status?: number);
12
- }
1
+ /**
2
+ * Error that should be compatible with express errors
3
+ */
4
+ export declare class RequestError extends Error {
5
+ readonly status: number;
6
+ /**
7
+ *
8
+ * @param message error message
9
+ * @param status status code to be reported
10
+ */
11
+ constructor(message: string, status?: number);
12
+ }
13
13
  //# sourceMappingURL=request-error.d.ts.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@donmahallem/turbo",
3
- "version": "2.3.8",
3
+ "version": "2.3.12",
4
4
  "description": "Turbo Helpers for express.js",
5
5
  "main": "dist/cjs/index.js",
6
6
  "module": "dist/esm/index.js",
@@ -53,13 +53,13 @@
53
53
  "devDependencies": {
54
54
  "@types/express": "4.17.13",
55
55
  "@types/supertest": "2.0.11",
56
- "axios": "0.25.0",
57
- "express": "4.17.2",
56
+ "axios": "0.26.1",
57
+ "express": "4.17.3",
58
58
  "supertest": "6.2.2"
59
59
  },
60
60
  "peerDependencies": {
61
- "axios": "^0.25.0",
61
+ "axios": "^0.26.0",
62
62
  "express": "^4.17.1"
63
63
  },
64
- "gitHead": "412e9dbe12ed9e22062db814fa3a4297cb3f6c12"
64
+ "gitHead": "359c24001a2388434489b7e8a0fdac0114ffa153"
65
65
  }