Ajout routes API PUT/DEL
This commit is contained in:
18
app.js
18
app.js
@@ -7,6 +7,8 @@ const fs = require('fs');
|
||||
const http = require('http');
|
||||
const https = require('https');
|
||||
|
||||
require('dotenv').config()
|
||||
|
||||
const certificate = fs.readFileSync(process.env.CLIENT_CRT || 'cert/client.crt', 'utf8');
|
||||
const privateKey = fs.readFileSync(process.env.CLIENT_KEY || 'cert/client.key', 'utf8');
|
||||
|
||||
@@ -115,15 +117,17 @@ app.use(function (req, res, next) {
|
||||
cbor.decodeFirst(req.body, (err, decoded) => {
|
||||
///// Check for error
|
||||
if (err) { res.sendStatus(418); return; }
|
||||
if (cbor_length > 0) {
|
||||
///// Assign decoded data
|
||||
req.body = decoded;
|
||||
json_length = JSON.stringify(decoded).length
|
||||
|
||||
///// Assign decoded data
|
||||
req.body = decoded;
|
||||
json_length = JSON.stringify(decoded).length
|
||||
///// Next handler
|
||||
console.log('Decoded:');
|
||||
console.log(req.body)
|
||||
console.log(cbor_length + ' Bytes (CBOR) -> ' + json_length + ' Bytes (JSON) -> ' + Math.round((cbor_length / json_length - 1) * 100) + '% reduction');
|
||||
}
|
||||
|
||||
///// Next handler
|
||||
console.log('Decoded:');
|
||||
console.log(req.body)
|
||||
console.log(cbor_length + ' Bytes (CBOR) -> ' + json_length + ' Bytes (JSON) -> ' + Math.round((cbor_length / json_length - 1) * 100) + '% reduction');
|
||||
next();
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user