aboutsummaryrefslogtreecommitdiff
path: root/api/routes/announceZBlock/index.js
diff options
context:
space:
mode:
authorkaotisk <kaotisk@arching-kaos.org>2024-03-01 02:47:10 +0200
committerkaotisk <kaotisk@arching-kaos.org>2024-03-01 02:47:10 +0200
commit6cb0efc1abeccd8f6a9c7ca7f209ff22c42341bd (patch)
tree17d514ffe79223d303229da97f114eebb4f3f052 /api/routes/announceZBlock/index.js
parent11cd4029ee6e1e5368be22742827dba1547cfc71 (diff)
downloadarching-kaos-tools-6cb0efc1abeccd8f6a9c7ca7f209ff22c42341bd.tar.gz
arching-kaos-tools-6cb0efc1abeccd8f6a9c7ca7f209ff22c42341bd.tar.bz2
arching-kaos-tools-6cb0efc1abeccd8f6a9c7ca7f209ff22c42341bd.zip
Renamed functions and routes
receive* -> announce* szbk -> /v0/announce/zblock szch -> /v0/announce/zchain
Diffstat (limited to 'api/routes/announceZBlock/index.js')
-rw-r--r--api/routes/announceZBlock/index.js29
1 files changed, 29 insertions, 0 deletions
diff --git a/api/routes/announceZBlock/index.js b/api/routes/announceZBlock/index.js
new file mode 100644
index 0000000..b395dbf
--- /dev/null
+++ b/api/routes/announceZBlock/index.js
@@ -0,0 +1,29 @@
+/*
+ * Accepts a ZBLOCK!
+ *
+ * Checks:
+ * 1. Exists,
+ * 2. Length is 46 bytes,
+ * 3. Matches regular expression /Qm[A-Za-z0-9]{44}/
+ *
+ * Returns:
+ * - error on failure
+ * - on success the string is processed for further
+ * validation to the function getvalidity()
+ *
+ */
+const getvalidity = require('../../validators/ZblockValidator')
+module.exports = (req, res) => {
+ console.log(req);
+ console.log("okay we got called");
+ if ( (req.body.zblock) && req.body.zblock.length === 46 ){
+ regex= /Qm[A-Za-z0-9]{44}/;
+ if (regex.test(req.body.zblock)){
+ getvalidity(req.body.zblock,res);
+ } else {
+ res.send({error:"Invalid data"});
+ }
+ } else {
+ res.send({error:"Invalid data"});
+ }
+}