aboutsummaryrefslogtreecommitdiff
path: root/api/routes/getZblock
diff options
context:
space:
mode:
authorkaotisk <kaotisk@arching-kaos.org>2023-08-03 10:43:32 +0300
committerkaotisk <kaotisk@arching-kaos.org>2023-08-03 10:43:32 +0300
commit67450601ebcbf4cd31d316e9e9a8a339a0719766 (patch)
tree2e95802f46c87bd522898f3f8dd5094366d6a348 /api/routes/getZblock
parenteb83dc73c0f71b2cf3480b17658ef7f21e92e570 (diff)
downloadarching-kaos-tools-67450601ebcbf4cd31d316e9e9a8a339a0719766.tar.gz
arching-kaos-tools-67450601ebcbf4cd31d316e9e9a8a339a0719766.tar.bz2
arching-kaos-tools-67450601ebcbf4cd31d316e9e9a8a339a0719766.zip
Changed to get params instead of query
Diffstat (limited to 'api/routes/getZblock')
-rw-r--r--api/routes/getZblock/index.js19
1 files changed, 11 insertions, 8 deletions
diff --git a/api/routes/getZblock/index.js b/api/routes/getZblock/index.js
index 7787d23..878c240 100644
--- a/api/routes/getZblock/index.js
+++ b/api/routes/getZblock/index.js
@@ -26,29 +26,32 @@ function fetchZblock(zblock, res){
command.on("close", code => {
console.log(`child process exited with code ${code}`);
- if ( code == 0 ) {
- const path = config.zblockDir+"/"+zblock;
+ if ( code === 0 ) {
+ const path = config.cacheDir+"/fzblocks/"+zblock;
+ console.log(path)
try {
if(fs.existsSync(path)){
res.send(JSON.parse(fs.readFileSync(path)));
}
} catch (error) {
- res.send({"error":error});
+ res.send({"error":error.message});
}
+ } else if ( code === 2){
+ res.send({"error":"The roof is on fire"});
} else {
res.send({"error":"invalid or unreachable"});
}
});
};
module.exports = (req, res) => {
- console.log(req.query)
- if ( (req.query.zblock) && req.query.zblock.length === 46 ){
+ console.log(req.params)
+ if ( (req.params.zblock) && req.params.zblock.length === 46 ){
regex= /Qm[A-Za-z0-9]{44}/;
- if (regex.test(req.query.zblock)){
- if (req.query.zblock === "QmbFMke1KXqnYyBBWxB74N4c5SBnJMVAiMNRcGu6x1AwQH" ){
+ if (regex.test(req.params.zblock)){
+ if (req.params.zblock === "QmbFMke1KXqnYyBBWxB74N4c5SBnJMVAiMNRcGu6x1AwQH" ){
res.send({error:"Genesis block"});
} else {
- fetchZblock(req.query.zblock,res);
+ fetchZblock(req.params.zblock,res);
}
} else {
res.send({error:"Invalid data: regexp failed to pass"});