-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
43 lines (39 loc) · 1.04 KB
/
index.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
require("dotenv").config();
const serverless = require("serverless-http");
const express = require("express");
const fetch = require("node-fetch");
const cors = require("cors");
const API_URL = process.env.API_URL;
const app = express();
app.use(cors());
app.get("/ialsearch", function (req, res) {
const params = new URLSearchParams(req.query).toString();
fetch(`${API_URL}/ialsearch?${params}`)
.then((data) => data.json())
.then((json) => {
res.json(json);
})
.catch((err) =>
res.json({
error: {
msg: `Unable to connect to MAS IAL API due to ${err}`,
},
})
);
});
app.get("/ialsuggest", function (req, res) {
const params = new URLSearchParams(req.query).toString();
fetch(`${API_URL}/ialsuggest?${params}`)
.then((data) => data.json())
.then((json) => {
res.json(json);
})
.catch((err) =>
res.json({
error: {
msg: `Unable to connect to MAS IAL API due to ${err}`,
},
})
);
});
module.exports.handler = serverless(app);