mirror of
https://github.com/IT4Change/gradido.git
synced 2026-01-20 20:01:31 +00:00
move DHT connection into main
This commit is contained in:
parent
51cc3164b2
commit
8aac319895
@ -21,7 +21,10 @@ const nodeAPI = {
|
||||
API_2_00: `${nodeURL}/graphql/2_00/`,
|
||||
}
|
||||
|
||||
export const startDHT = async (connection: Connection, topic: string): Promise<void> => {
|
||||
export const startDHT = async (
|
||||
connection: Connection,
|
||||
topic: string,
|
||||
): Promise<void> => {
|
||||
try {
|
||||
const TOPIC = DHT.hash(Buffer.from(topic))
|
||||
|
||||
|
||||
@ -1,12 +1,13 @@
|
||||
/* eslint-disable @typescript-eslint/no-explicit-any */
|
||||
|
||||
import createServer from './server/createServer'
|
||||
import { startDHT } from '@/federation/index'
|
||||
|
||||
// config
|
||||
import CONFIG from './config'
|
||||
|
||||
async function main() {
|
||||
const { app } = await createServer()
|
||||
const { app, con } = await createServer()
|
||||
|
||||
app.listen(CONFIG.PORT, () => {
|
||||
// eslint-disable-next-line no-console
|
||||
@ -16,6 +17,11 @@ async function main() {
|
||||
console.log(`GraphIQL available at http://localhost:${CONFIG.PORT}`)
|
||||
}
|
||||
})
|
||||
|
||||
// start DHT hyperswarm when DHT_TOPIC is set in .env
|
||||
if (CONFIG.DHT_TOPIC) {
|
||||
await startDHT(con, CONFIG.DHT_TOPIC)
|
||||
}
|
||||
}
|
||||
|
||||
main().catch((e) => {
|
||||
|
||||
@ -22,9 +22,6 @@ import schema from '@/graphql/schema'
|
||||
import { elopageWebhook } from '@/webhook/elopage'
|
||||
import { Connection } from '@dbTools/typeorm'
|
||||
|
||||
// DHT
|
||||
import { startDHT } from '@/federation/index'
|
||||
|
||||
import { apolloLogger } from './logger'
|
||||
import { Logger } from 'log4js'
|
||||
|
||||
@ -55,11 +52,6 @@ const createServer = async (
|
||||
throw new Error('Fatal: Database Version incorrect')
|
||||
}
|
||||
|
||||
// start DHT hyperswarm when DHT_TOPIC is set in .env
|
||||
if (CONFIG.DHT_TOPIC) {
|
||||
await startDHT(con, CONFIG.DHT_TOPIC)
|
||||
}
|
||||
|
||||
// Express Server
|
||||
const app = express()
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user