Avatar

juliendorra

2 public vals
Joined March 15, 2023
1
2
3
4
5
6
7
export let geolocation = async (req, res) => {
const ip = req.options.headers["x-forwarded-for"];
const jsonresponse = await $stevekrouse.fetchJSON(
`http://ip-api.com/json/${ip}`
);
res.json({ ip: req });
};
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
export let mockdevices = (user) => {
// use user name to select devices
let devices = [];
let id = 0;
for (let letter of user) {
// add a device if charcode is even
if (letter.charCodeAt() % 2 === 0) {
// pick type
let type;
if (letter.charCodeAt() % 3 === 0) {
type = "thermostat";
} else {
type = "camera";
}
devices.push({
id: id,
type: type,
online: true,
});
id++;
}
}
return devices;
};
Next