-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathproxy.js
35 lines (29 loc) · 833 Bytes
/
proxy.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 PORT = 8080;
const express = require("express");
const cors = require("cors");
const axios = require("axios");
const bodyParser = require('body-parser');
require("dotenv").config();
const app = express();
app.use(cors());
app.use(bodyParser.urlencoded({ extended: true }));
app.post("/sparql", (req, res) => {
console.log('Got body:', req.body);
const options = {
method: "GET",
url: req.body.endpoint + req.body.query,
}
axios
.request(options)
.then((response) => {
console.log('Request processed successfully');
res.json(response.data);
})
.catch((error) => {
console.log('Request failed');
res.json(error);
});
});
app.listen(PORT, () => {
console.log(`Server is running on port ${PORT}`);
});