-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathapp.js
37 lines (31 loc) · 898 Bytes
/
app.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
36
37
const oracleConnection = require("./database");
const express = require("express");
const bodyParser = require("body-parser");
const app = express();
app.use(bodyParser.json());
app.get("/query", (req, res) => {
const query = req.body.query;
oracleConnection.then((connect) => {
connect.execute(query).then((data) => {
console.log(data.rows);
res.send(JSON.stringify(data.rows[0]));
});
});
});
app.post("/query", (req, res) => {
const query = req.body.query;
console.log(JSON.stringify(req.body));
oracleConnection.then((connect) => {
connect.execute(query).then((data) => {
console.log(data.rows);
res.send(JSON.stringify(data.rows));
});
});
});
app.use((err, req, res, next) => {
console.error(err.stack);
res.status(500).send("Something broke!");
});
app.listen(5001, () => {
console.log("server is running on port 5001");
});