|
|
|
@ -97,17 +97,22 @@ app.get('/view/:baseView', async (req, res) => { |
|
|
|
|
|
|
|
app.get('/publish', async (req, res) => { |
|
|
|
const data = await readJSONFile('./block.json'); |
|
|
|
let responseData; |
|
|
|
|
|
|
|
const response = await fetch(`${blocksRegistry}`, { |
|
|
|
method: 'POST', |
|
|
|
body: JSON.stringify(data), |
|
|
|
headers: {'Content-Type': 'application/json'} |
|
|
|
}); |
|
|
|
try { |
|
|
|
const response = await fetch(`${blocksRegistry}`, { |
|
|
|
method: 'POST', |
|
|
|
body: JSON.stringify(data), |
|
|
|
headers: {'Content-Type': 'application/json'} |
|
|
|
}); |
|
|
|
|
|
|
|
const responseData = await response.json(); |
|
|
|
responseData = await response.json(); |
|
|
|
} catch (e) { |
|
|
|
res.json({success: false, message: 'Blocks Registry server is not available.'}); |
|
|
|
return; |
|
|
|
} |
|
|
|
|
|
|
|
if (responseData.statusCode !== 200) { |
|
|
|
console.log(responseData); |
|
|
|
res.json({success: false, message: 'Error on registry level.'}); |
|
|
|
return; |
|
|
|
} |
|
|
|
@ -123,11 +128,13 @@ app.get('/publish', async (req, res) => { |
|
|
|
|
|
|
|
if (response.status !== 200) { |
|
|
|
res.json({success: false, message: "Can't upload the archive, permissions error."}); |
|
|
|
// TODO: Need to update the registry server.
|
|
|
|
await fs.unlink('./dist.zip'); |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
res.json({success: true}); |
|
|
|
|
|
|
|
await fs.unlink('./dist.zip'); |
|
|
|
|