mirror of
https://github.com/IT4Change/gradido.git
synced 2025-12-13 07:45:54 +00:00
try using dht if DHT_TOPIC is set in .env
This commit is contained in:
parent
e2efd0da9d
commit
d514886728
12
backend/src/federation/index.ts
Normal file
12
backend/src/federation/index.ts
Normal file
@ -0,0 +1,12 @@
|
||||
import DHT from '@hyperswarm/dht'
|
||||
import { Connection } from '@dbTools/typeorm'
|
||||
|
||||
const POLLTIME = 20000
|
||||
const SUCCESSTIME = 120000
|
||||
const ERRORTIME = 240000
|
||||
const ANNOUNCETIME = 30000
|
||||
|
||||
export const startDHT = async (connection: Connection, topic: string): Promise<void> => {
|
||||
console.log('topic', topic, typeof topic)
|
||||
// const TOPIC = DHT.hash(Buffer.from(topic))
|
||||
}
|
||||
@ -22,6 +22,9 @@ import schema from '@/graphql/schema'
|
||||
import { elopageWebhook } from '@/webhook/elopage'
|
||||
import { Connection } from '@dbTools/typeorm'
|
||||
|
||||
// DHT
|
||||
import { startDHT } from '@/federation/index'
|
||||
|
||||
// TODO implement
|
||||
// import queryComplexity, { simpleEstimator, fieldConfigEstimator } from "graphql-query-complexity";
|
||||
|
||||
@ -41,6 +44,12 @@ const createServer = async (context: any = serverContext): Promise<ServerDef> =>
|
||||
throw new Error('Fatal: Database Version incorrect')
|
||||
}
|
||||
|
||||
// start DHT hyperswarm when DHT_TOPIC is set in .env
|
||||
if (CONFIG.DHT_TOPIC) {
|
||||
console.log('Starting hyperswarm DHT')
|
||||
await startDHT(con, CONFIG.DHT_TOPIC)
|
||||
}
|
||||
|
||||
// Express Server
|
||||
const app = express()
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user