-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
34 lines (30 loc) · 885 Bytes
/
index.js
File metadata and controls
34 lines (30 loc) · 885 Bytes
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
const express = require('express')
const app = express()
const cors = require('cors')
const http = require('http')
const querystring = require('querystring')
const axios = require('axios');
var bodyParser = require('body-parser')
app.use(bodyParser.urlencoded({ extended: false }))
app.use(bodyParser.json({ limit: '500mb' }))
app.use(cors())
const caxy = (htmlOld, htmlNew) =>
axios.post('http://php-htmldiff-api.caxy.com/diff/caxy_htmldiff', {
htmlNew,
htmlOld
})
app.post('/', (req, res, next) => {
const htmlNew = req.body.htmlNew
const htmlOld = req.body.htmlOld
console.log(htmlNew)
console.log(htmlOld)
return caxy(htmlOld, htmlNew)
.then(response => ({
diff: response.data, path: htmlOld.path
}))
.then(x => res.send(x))
.catch(next)
})
app.listen(8000, () => {
console.log('Example app listening on port 8000!')
});