-
Notifications
You must be signed in to change notification settings - Fork 7
/
server.js
46 lines (39 loc) · 1.02 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
const express = require("express");
const dotenv = require("dotenv");
dotenv.config();
const jexiaSDK = require("jexia-sdk-js/node");
const dataModule = jexiaSDK.dataOperations();
const field = jexiaSDK.field();
const credentials = {
projectID: process.env.PROJECT_ID,
key: process.env.API_KEY,
secret:process.env.API_SECRET
};
jexiaSDK.jexiaClient().init( credentials,dataModule);
const todo = dataModule.dataset(process.env.DATASET);
// if you want to run locally change port to 3000
// for Apphosting use port 80
const PORT = 80;
// to deploy it to AppHosting please use IP:0.0.0.0
const HOST = '0.0.0.0';
// App
const app = express();
app.get('/', (req, res) => {
todo
.select()
.limit(200)
.fields("text", "id","done")
.where(field=> field("text").isLike("%4").and(field("id").isNotNull()))
.subscribe(
records => {
console.log(records)
res.send(records)
},
error => {
console.log(error)
next(error)
}
);
});
app.listen(PORT, HOST);
console.log(`Running on http://${HOST}:${PORT}`);