@atomiqlabs/lp-lib 16.0.9 → 16.0.10

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.
@@ -18,20 +18,19 @@ class InfoHandler {
18
18
  * @param restServer
19
19
  */
20
20
  startRestServer(restServer) {
21
- restServer.use(this.path + "/info", express.json());
22
- restServer.post(this.path + "/info", async (req, res) => {
23
- if (req.body == null ||
24
- req.body.nonce == null ||
25
- typeof (req.body.nonce) !== "string" ||
26
- req.body.nonce.length > 64 ||
27
- !HEX_REGEX.test(req.body.nonce)) {
21
+ const infoHandler = async (req, res) => {
22
+ const reqParams = { ...req.body, ...req.query };
23
+ if (reqParams.nonce == null ||
24
+ typeof (reqParams.nonce) !== "string" ||
25
+ reqParams.nonce.length > 64 ||
26
+ !HEX_REGEX.test(reqParams.nonce)) {
28
27
  res.status(400).json({
29
28
  msg: "Invalid request body (nonce)"
30
29
  });
31
30
  return;
32
31
  }
33
32
  const env = {
34
- nonce: req.body.nonce,
33
+ nonce: reqParams.nonce,
35
34
  services: {}
36
35
  };
37
36
  for (let swapHandler of this.swapHandlers) {
@@ -52,7 +51,10 @@ class InfoHandler {
52
51
  chains
53
52
  };
54
53
  res.status(200).json(response);
55
- });
54
+ };
55
+ restServer.use(this.path + "/info", express.json());
56
+ restServer.post(this.path + "/info", infoHandler);
57
+ restServer.get(this.path + "/info", infoHandler);
56
58
  }
57
59
  }
58
60
  exports.InfoHandler = InfoHandler;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atomiqlabs/lp-lib",
3
- "version": "16.0.9",
3
+ "version": "16.0.10",
4
4
  "description": "Main functionality implementation for atomiq LP node",
5
5
  "main": "./dist/index.js",
6
6
  "types:": "./dist/index.d.ts",
@@ -44,15 +44,14 @@ export class InfoHandler {
44
44
  */
45
45
  startRestServer(restServer: Express) {
46
46
 
47
- restServer.use(this.path+"/info", express.json());
48
- restServer.post(this.path+"/info", async (req, res) => {
49
- if (
50
- req.body == null ||
47
+ const infoHandler = async (req, res) => {
48
+ const reqParams = {...req.body, ...req.query};
51
49
 
52
- req.body.nonce == null ||
53
- typeof(req.body.nonce) !== "string" ||
54
- req.body.nonce.length>64 ||
55
- !HEX_REGEX.test(req.body.nonce)
50
+ if (
51
+ reqParams.nonce == null ||
52
+ typeof(reqParams.nonce) !== "string" ||
53
+ reqParams.nonce.length>64 ||
54
+ !HEX_REGEX.test(reqParams.nonce)
56
55
  ) {
57
56
  res.status(400).json({
58
57
  msg: "Invalid request body (nonce)"
@@ -61,7 +60,7 @@ export class InfoHandler {
61
60
  }
62
61
 
63
62
  const env: InfoHandlerResponseEnvelope = {
64
- nonce: req.body.nonce,
63
+ nonce: reqParams.nonce,
65
64
  services: {}
66
65
  };
67
66
 
@@ -92,7 +91,11 @@ export class InfoHandler {
92
91
  };
93
92
 
94
93
  res.status(200).json(response);
95
- });
94
+ };
95
+
96
+ restServer.use(this.path+"/info", express.json());
97
+ restServer.post(this.path+"/info", infoHandler);
98
+ restServer.get(this.path+"/info", infoHandler);
96
99
 
97
100
  }
98
101