-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
31 lines (26 loc) · 894 Bytes
/
index.js
File metadata and controls
31 lines (26 loc) · 894 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
const express = require('express');
const fetch = require('node-fetch');
const {data, AnalyzingCurrentTemp} = require("./Utils")
const cors = require('cors');
const app = express();
// returns code coverage information if available
// https://github.com/cypress-io/code-coverage
/* istanbul ignore next */
if (global.__coverage__) {
require('@cypress/code-coverage/middleware/express')(app)
}
const port = 8081;
app.use(cors());
app.get('/api/temperature/:id', (req, res) => {
fetch(
`https://hasydbj5c4gpa2oozfpjpc677a0hxuob.lambda-url.ap-southeast-2.on.aws/sensor/${req.params.id}`
)
.then((response) => response.json())
.then((response) => res.send(AnalyzingCurrentTemp(response)));
});
app.get('/api/productList', (req, res) => {
res.json(data);
});
app.listen(port, () => {
console.log(`SensorTech server at http://localhost:${port}`);
});