-
Notifications
You must be signed in to change notification settings - Fork 11
/
index.js
42 lines (36 loc) · 1002 Bytes
/
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
const { Neurosity } = require("@neurosity/sdk");
require('dotenv').config();
const deviceId = process.env.DEVICE_ID || "";
const email = process.env.EMAIL || "";
const password = process.env.PASSWORD || "";
const verifyEnvs = (email, password, deviceId) => {
const invalidEnv = (env) => {
return (env === "");
}
if (invalidEnv(email) || invalidEnv(password) || invalidEnv(deviceId)) {
console.error("Please verify deviceId, email and password are in .env file, quitting...");
process.exit(0);
}
}
verifyEnvs(email, password, deviceId);
console.log(`${email} attempting to authenticate with ${deviceId}`);
const neurosity = new Neurosity({
deviceId
});
const main = async () => {
await neurosity.login({
email,
password
})
.catch(error => {
console.log(error);
throw new Error(error);
});
console.log("Logged in");
neurosity.calm().subscribe((calm) => {
if (calm.probability > 0.3) {
console.log("Hello world");
}
});
}
main();