-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathserver.js
73 lines (53 loc) · 1.51 KB
/
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
const express = require("express");
const set_paymentData = require("./services/mpesa.js");
const robots = require("./services/robots/index.js");
const state = require("./services/robots/state.js");
const app = express();
const port = process.env.PORT || 4000;
app.get("/", async (req, res) => {
res.send("Hello World!");
});
app.get(
"/api/mpesa/payment/:number-:reference-:transaction-:amount",
async (req, res) => {
var number = req.params.number;
var reference = req.params.reference;
var transaction = req.params.transaction;
var amount = req.params.amount;
await set_paymentData(number, reference, transaction, amount);
}
);
app.get("/api/site/:type", async (req, res) => {
const content = {
searchTerm: req.params.type,
lang: "pt",
portal :[]
};
await robots.sitereader.read(content);
res.send(content);
});
app.get("/api/site/:type/:category", async (req, res) => {
const content = {
searchTerm: req.params.type,
lang: "pt",
category: req.params.category,
portal :[]
};
await robots.sitereader.read(content);
res.send(content.website);
});
app.get("/api/robot/:textsearch", async (req, res) => {
const content = {
searchTerm: req.params.textsearch,
lang: "en",
maximumSentences: 7,
};
state.save(content);
await robots.text(content);
await robots.image();
await robots.video();
res.send(content.sourceContentOriginal);
});
app.listen(port, () => {
console.log(`Example app listening at http://localhost:${port}`);
});