forked from allmightybob1/xsoar-marketplace.pan.dev
-
Notifications
You must be signed in to change notification settings - Fork 0
/
mdx-parse-server.js
36 lines (32 loc) · 910 Bytes
/
mdx-parse-server.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
const mdx = require('@mdx-js/mdx');
const http = require('http')
function requestHandler(req, res) {
// console.log(req)
if (req.method != 'POST') {
res.statusCode = 405
res.end('Only POST is supported')
return
}
let body = ''
req.setEncoding('utf8');
req.on('data', function (data) {
body += data
})
req.on('end', async function () {
// console.log('Body length: ' + body.length)
try {
parsed = await mdx(body)
res.end('Successfully parsed mdx')
} catch (error) {
res.statusCode = 500
res.end("MDX parse failure: " + error)
}
})
}
const server = http.createServer(requestHandler);
server.listen(6060, (err) => {
if (err) {
return console.log('something bad happened', err)
}
console.log(`MDS server is listening on port: 6060`)
});