@lodestar/api 1.20.0-dev.d101913ca3 → 1.20.0-dev.dbd44b2d56
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/README.md +8 -15
- package/lib/beacon/client/events.js +2 -1
- package/lib/beacon/client/events.js.map +1 -1
- package/lib/beacon/routes/beacon/block.d.ts +14 -13
- package/lib/beacon/routes/beacon/block.js +23 -31
- package/lib/beacon/routes/beacon/block.js.map +1 -1
- package/lib/beacon/routes/debug.d.ts +9 -28
- package/lib/beacon/routes/debug.js +9 -43
- package/lib/beacon/routes/debug.js.map +1 -1
- package/lib/beacon/routes/events.d.ts +4 -4
- package/lib/beacon/routes/events.js +1 -1
- package/lib/beacon/routes/events.js.map +1 -1
- package/lib/beacon/routes/lightclient.d.ts +5 -5
- package/lib/beacon/routes/lightclient.js +1 -1
- package/lib/beacon/routes/lightclient.js.map +1 -1
- package/lib/beacon/routes/validator.d.ts +7 -35
- package/lib/beacon/routes/validator.js +3 -29
- package/lib/beacon/routes/validator.js.map +1 -1
- package/lib/builder/routes.d.ts +4 -4
- package/lib/builder/routes.js +5 -5
- package/lib/builder/routes.js.map +1 -1
- package/lib/utils/client/response.d.ts +1 -0
- package/lib/utils/client/response.js +15 -14
- package/lib/utils/client/response.js.map +1 -1
- package/lib/utils/fork.d.ts +5 -6
- package/lib/utils/fork.js +5 -11
- package/lib/utils/fork.js.map +1 -1
- package/lib/utils/server/handler.js +38 -40
- package/lib/utils/server/handler.js.map +1 -1
- package/package.json +7 -7
|
@@ -25,50 +25,44 @@ export function createFastifyHandler(definition, method, _operationId) {
|
|
|
25
25
|
}
|
|
26
26
|
}
|
|
27
27
|
const responseWireFormat = responseMediaType !== null ? getWireFormat(responseMediaType) : null;
|
|
28
|
-
let
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
28
|
+
let requestWireFormat;
|
|
29
|
+
if (isRequestWithoutBody(definition)) {
|
|
30
|
+
requestWireFormat = null;
|
|
31
|
+
}
|
|
32
|
+
else {
|
|
33
|
+
const contentType = req.headers[HttpHeader.ContentType];
|
|
34
|
+
if (contentType === undefined && req.body === undefined) {
|
|
35
|
+
// Default to json parser if body is omitted. This is not possible for most
|
|
36
|
+
// routes as request will fail schema validation before this handler is called
|
|
37
|
+
requestWireFormat = WireFormat.json;
|
|
35
38
|
}
|
|
36
39
|
else {
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
if (contentType === undefined && req.body === undefined) {
|
|
40
|
-
// Default to json parser if body is omitted. This is not possible for most
|
|
41
|
-
// routes as request will fail schema validation before this handler is called
|
|
42
|
-
requestWireFormat = WireFormat.json;
|
|
43
|
-
}
|
|
44
|
-
else {
|
|
45
|
-
if (contentType === undefined) {
|
|
46
|
-
throw new ApiError(400, "Content-Type header is required");
|
|
47
|
-
}
|
|
48
|
-
const requestMediaType = parseContentTypeHeader(contentType);
|
|
49
|
-
if (requestMediaType === null) {
|
|
50
|
-
throw new ApiError(415, `Unsupported media type: ${contentType.split(";", 1)[0]}`);
|
|
51
|
-
}
|
|
52
|
-
requestWireFormat = getWireFormat(requestMediaType);
|
|
53
|
-
}
|
|
54
|
-
const { onlySupport } = definition.req;
|
|
55
|
-
if (onlySupport !== undefined && onlySupport !== requestWireFormat) {
|
|
56
|
-
throw new ApiError(415, `Endpoint only supports ${onlySupport.toUpperCase()} requests`);
|
|
40
|
+
if (contentType === undefined) {
|
|
41
|
+
throw new ApiError(400, "Content-Type header is required");
|
|
57
42
|
}
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
sszBytes: null,
|
|
62
|
-
returnBytes: responseWireFormat === WireFormat.ssz,
|
|
63
|
-
});
|
|
64
|
-
break;
|
|
65
|
-
case WireFormat.ssz:
|
|
66
|
-
response = await method(definition.req.parseReqSsz(req), {
|
|
67
|
-
sszBytes: req.body,
|
|
68
|
-
returnBytes: responseWireFormat === WireFormat.ssz,
|
|
69
|
-
});
|
|
70
|
-
break;
|
|
43
|
+
const requestMediaType = parseContentTypeHeader(contentType);
|
|
44
|
+
if (requestMediaType === null) {
|
|
45
|
+
throw new ApiError(415, `Unsupported media type: ${contentType.split(";", 1)[0]}`);
|
|
71
46
|
}
|
|
47
|
+
requestWireFormat = getWireFormat(requestMediaType);
|
|
48
|
+
}
|
|
49
|
+
const { onlySupport } = definition.req;
|
|
50
|
+
if (onlySupport !== undefined && onlySupport !== requestWireFormat) {
|
|
51
|
+
throw new ApiError(415, `Endpoint only supports ${onlySupport.toUpperCase()} requests`);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
let args;
|
|
55
|
+
try {
|
|
56
|
+
switch (requestWireFormat) {
|
|
57
|
+
case WireFormat.json:
|
|
58
|
+
args = definition.req.parseReqJson(req);
|
|
59
|
+
break;
|
|
60
|
+
case WireFormat.ssz:
|
|
61
|
+
args = definition.req.parseReqSsz(req);
|
|
62
|
+
break;
|
|
63
|
+
case null:
|
|
64
|
+
args = definition.req.parseReq(req);
|
|
65
|
+
break;
|
|
72
66
|
}
|
|
73
67
|
}
|
|
74
68
|
catch (e) {
|
|
@@ -77,6 +71,10 @@ export function createFastifyHandler(definition, method, _operationId) {
|
|
|
77
71
|
// Errors related to parsing should return 400 status code
|
|
78
72
|
throw new ApiError(400, e.message);
|
|
79
73
|
}
|
|
74
|
+
const response = await method(args, {
|
|
75
|
+
sszBytes: requestWireFormat === WireFormat.ssz ? req.body : null,
|
|
76
|
+
returnBytes: responseWireFormat === WireFormat.ssz,
|
|
77
|
+
});
|
|
80
78
|
if (response?.status !== undefined) {
|
|
81
79
|
resp.statusCode = response.status;
|
|
82
80
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"handler.js","sourceRoot":"","sources":["../../../src/utils/server/handler.ts"],"names":[],"mappings":"AAEA,OAAO,EAAC,UAAU,EAAE,SAAS,EAAE,qBAAqB,EAAE,iBAAiB,EAAE,sBAAsB,EAAC,MAA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C,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,QAAQ,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,CAAC,CAAC;gBACrE,4EAA4E;gBAC5E,mFAAmF;gBACnF,OAAO,IAAI,CAAC;YACd,CAAC;YACD,KAAK,IAAI;gBACP,6BAA6B;gBAC7B,OAAO;QACX,CAAC;IACH,CAAC,CAAC;AACJ,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lodestar/api",
|
|
3
|
-
"description": "A Typescript
|
|
3
|
+
"description": "A Typescript REST client for the Ethereum Consensus API",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"author": "ChainSafe Systems",
|
|
6
6
|
"homepage": "https://github.com/ChainSafe/lodestar#readme",
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
"bugs": {
|
|
12
12
|
"url": "https://github.com/ChainSafe/lodestar/issues"
|
|
13
13
|
},
|
|
14
|
-
"version": "1.20.0-dev.
|
|
14
|
+
"version": "1.20.0-dev.dbd44b2d56",
|
|
15
15
|
"type": "module",
|
|
16
16
|
"exports": {
|
|
17
17
|
".": {
|
|
@@ -72,10 +72,10 @@
|
|
|
72
72
|
"dependencies": {
|
|
73
73
|
"@chainsafe/persistent-merkle-tree": "^0.7.1",
|
|
74
74
|
"@chainsafe/ssz": "^0.15.1",
|
|
75
|
-
"@lodestar/config": "1.20.0-dev.
|
|
76
|
-
"@lodestar/params": "1.20.0-dev.
|
|
77
|
-
"@lodestar/types": "1.20.0-dev.
|
|
78
|
-
"@lodestar/utils": "1.20.0-dev.
|
|
75
|
+
"@lodestar/config": "1.20.0-dev.dbd44b2d56",
|
|
76
|
+
"@lodestar/params": "1.20.0-dev.dbd44b2d56",
|
|
77
|
+
"@lodestar/types": "1.20.0-dev.dbd44b2d56",
|
|
78
|
+
"@lodestar/utils": "1.20.0-dev.dbd44b2d56",
|
|
79
79
|
"eventsource": "^2.0.2",
|
|
80
80
|
"qs": "^6.11.1"
|
|
81
81
|
},
|
|
@@ -92,5 +92,5 @@
|
|
|
92
92
|
"api",
|
|
93
93
|
"blockchain"
|
|
94
94
|
],
|
|
95
|
-
"gitHead": "
|
|
95
|
+
"gitHead": "c8c294d9e40501658cb62e1e785c87a38f089eeb"
|
|
96
96
|
}
|