-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.ts
51 lines (44 loc) · 1.46 KB
/
index.ts
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
47
48
49
50
51
/**
* Created by Farmas on 21.02.2017.
*/
import * as express from "express";
import * as schedule from "node-schedule";
import * as req from "request";
import { GraphqlServer } from "./graphql/index";
import { insertHour } from "./service/HourService";
import { example } from "./datasourceexample";
import { calculateExampleLSTM } from "./neural/index";
const app = express();
const PORT = 1000;
const PORTQRAPHQLSERVICE = 2000;
const getUsersGithubInfo = (user: string, callback) => {
req.get(`https://api.github.com/users/${user}`,
{headers: {'User-Agent': 'Awesome-Octocat-App'}},
(error, res, body) => {
callback(body)
});
};
app.get('/find-me-on-github/:user', (request, response) => {
getUsersGithubInfo(request.params.user, (body) => response.send(`
<pre>${JSON.stringify(JSON.parse(body), null, 2)}</pre>
`));
});
app.get('/trigger', async(request, response) => {
console.log("trigger shall begun")
const insertedThingy = await insertHour(example);
console.log(insertedThingy)
response.send(insertedThingy)
});
app.get('/trigger2', (request, response) => {
calculateExampleLSTM()
response.send("hello")
});
app.listen(PORT, () => {
const scheduled = schedule.scheduleJob('0 30 * * * *', () =>
console.log('hello from scheduledJob')
);
console.log(`Start is up and running on localhost:${PORT}`)
});
GraphqlServer.listen(PORTQRAPHQLSERVICE, () => {
console.log(`QraphQL is up and running on localhost:${PORTQRAPHQLSERVICE}`)
});