-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.ts
59 lines (53 loc) · 1.98 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
import 'dotenv/config'
import express, { Request, Response } from 'express'
import { logger } from './scripts/common/helpers/logger'
import { transferSsvTokensFromFactoryToClusters } from './scripts/ssv/writes/transferSsvTokensFromFactoryToClusters'
import { logEnv } from './scripts/common/helpers/logEnv'
import { removeExitedValidatorsFromClusters } from './scripts/ssv/writes/removeExitedValidatorsFromClusters'
import { withdrawExcessTokensFromClusters } from './scripts/ssv/writes/withdrawExcessTokensFromClusters'
const app = express()
app.get('/', (req: Request, res: Response) => {
res.send('p2p-ssv-cluster-manager server')
})
app.get(
'/01-transfer-ssv-tokens-from-factory-to-clusters',
async (req: Request, res: Response) => {
logger.info('01-transfer-ssv-tokens-from-factory-to-clusters started')
res.send(
'01-transfer-ssv-tokens-from-factory-to-clusters started at ' +
new Date().toISOString(),
)
logEnv()
await transferSsvTokensFromFactoryToClusters()
logger.info('01-transfer-ssv-tokens-from-factory-to-clusters finished')
},
)
app.get(
'/02-remove-exited-validators-from-clusters',
async (req: Request, res: Response) => {
logger.info('02-remove-exited-validators-from-clusters started')
res.send(
'02-remove-exited-validators-from-clusters started at ' +
new Date().toISOString(),
)
logEnv()
await removeExitedValidatorsFromClusters()
logger.info('02-remove-exited-validators-from-clusters finished')
},
)
app.get(
'/03-withdraw-excess-tokens-from-clusters',
async (req: Request, res: Response) => {
logger.info('03-withdraw-excess-tokens-from-clusters started')
res.send(
'03-withdraw-excess-tokens-from-clusters started at ' +
new Date().toISOString(),
)
logEnv()
await withdrawExcessTokensFromClusters()
logger.info('03-withdraw-excess-tokens-from-clusters finished')
},
)
app.listen(process.env.PORT, () =>
logger.info('Server started on port', process.env.PORT),
)