-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.ts
59 lines (47 loc) · 1.57 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
52
53
54
55
56
57
58
59
/* eslint-disable import/first */
import dotenv from 'dotenv';
dotenv.config();
import 'cross-fetch/polyfill';
import { utils } from 'ethers';
import { startBlockListener } from '~blockListener';
import amplifyClientSetup from '~amplifyClient';
import { initialiseProvider } from '~provider';
import { startStatsServer } from '~stats';
import {
setupListenersForColonies,
setupListenersForExtensions,
} from '~eventListeners';
import { seedDB } from '~utils';
import { setupNotificationsClient } from '~utils/notifications';
utils.Logger.setLogLevel(utils.Logger.levels.ERROR);
const start = async (): Promise<void> => {
amplifyClientSetup();
/**
* Setup the notifications provider so that notifications can be sent when needed
*/
await setupNotificationsClient();
/**
* Start express server providing stats and fetch existing stats from the DB
*/
await startStatsServer();
/**
* Setup the listeners we care about for existing colonies, extensions
* This has to be done before the block listener is started to ensure the events are not missed
*/
await setupListenersForColonies();
await setupListenersForExtensions();
/**
* Start the main block listener
*/
startBlockListener();
await initialiseProvider();
/**
* In development, where both the chain and the DB gets reset everytime,
* we need to "seed" some initial data, such as versions or the current network fee
* In live environments, these values will already have been saved in the DB
*/
if (process.env.NODE_ENV === 'development') {
await seedDB();
}
};
start();