-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup.ts
37 lines (33 loc) · 1.26 KB
/
setup.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
import { run as runCompanyAPI } from './ExternalServices/companyAPI'
import { run as runFlandersAPI } from './ExternalServices/flandersAPI'
import { LogStore, PolicyStore } from './SolidPod/Util/Storage'
import { startPod } from './SolidPod/index'
export function clearStores() {
console.log('')
console.log('######################################')
console.log('Clear log of agreements and policies in pod')
console.log('######################################')
console.log('')
console.log('')
new PolicyStore().clear()
new LogStore().clear()
}
export async function setup(podId: string) {
console.log('######################################')
console.log('Setting Up External APIs to fetch data')
console.log('######################################')
console.log('')
const company = await runCompanyAPI()
const flanders = await runFlandersAPI()
console.log('')
console.log('######################################')
console.log('Setting up Pod Interfaces')
console.log('######################################')
console.log('')
const pod = await startPod(podId)
return async () => {
await new Promise(res => company.close(res));
await new Promise(res => flanders.close(res));
await Promise.all(pod.map(p => p.stop()));
}
}