openreplay/sourcemapreader/servers/sourcemaps-server.js
Rajesh Rajendran 7f9ab3eb1d refactor(sourcemapreader): renaming sourcemap reader (#1676)
Helm chart, image, and sourcefolder are of different names, which causes
confusion and difficulties to automate builds.

Signed-off-by: rjshrjndrn <rjshrjndrn@gmail.com>
2023-11-20 16:15:12 +01:00

30 lines
No EOL
951 B
JavaScript

const express = require('express');
const handler = require('./sourcemaps-handler');
const router = express.Router();
router.post('/', (req, res) => {
let data = '';
req.on('data', chunk => {
data += chunk;
});
req.on('end', function () {
data = JSON.parse(data);
console.log(`[SR] Starting parser for ${data.isURL ? "URL: " : "file: "}${data.key}`);
// process.env = {...process.env, ...data.bucket_config};
handler.sourcemapReader(data)
.then((results) => {
res.statusCode = 200;
res.setHeader('Content-Type', 'application/json');
res.end(JSON.stringify(results));
})
.catch((e) => {
console.error("[SR] Something went wrong");
console.error(e);
res.statusCode = 500;
res.end(e.toString());
});
})
});
module.exports = router;