updated network version and bug fixes

This commit is contained in:
anonpenguin 2025-04-08 14:22:23 +03:00
parent 84de28793d
commit f81171c2fe
5 changed files with 736 additions and 21 deletions

View File

@ -32,7 +32,7 @@
"dependencies": { "dependencies": {
"@anyone-protocol/anyone-client": "^0.4.4", "@anyone-protocol/anyone-client": "^0.4.4",
"@debros/cli": "^0.0.11-alpha", "@debros/cli": "^0.0.11-alpha",
"@debros/network": "^0.0.16-alpha", "@debros/network": "^0.0.22-alpha",
"@helia/unixfs": "^4.0.3", "@helia/unixfs": "^4.0.3",
"@libp2p/bootstrap": "^11.0.32", "@libp2p/bootstrap": "^11.0.32",
"@libp2p/crypto": "^5.0.15", "@libp2p/crypto": "^5.0.15",

732
pnpm-lock.yaml generated

File diff suppressed because it is too large Load Diff

View File

@ -9,7 +9,7 @@ export const registerHealthEndpoints = (app: express.Application) => {
// Health check endpoint that also reports node load and peers // Health check endpoint that also reports node load and peers
app.get('/health', (req, res) => { app.get('/health', (req, res) => {
const connectedPeers = getConnectedPeers(); const connectedPeers = getConnectedPeers();
const peerCount = connectedPeers.length; const peerCount = connectedPeers.size;
res.json({ res.json({
status: 'healthy', status: 'healthy',
@ -28,7 +28,7 @@ export const startStatusReporting = (interval = 600000) => {
// Schedule a status report every 10 minutes // Schedule a status report every 10 minutes
return setInterval(() => { return setInterval(() => {
const connectedPeers = getConnectedPeers(); const connectedPeers = getConnectedPeers();
const peerCount = connectedPeers.length; const peerCount = connectedPeers.size;
console.log('==== DEBROS STATUS REPORT ===='); console.log('==== DEBROS STATUS REPORT ====');
console.log(`📊 Fingerprint: ${config.env.fingerprint}`); console.log(`📊 Fingerprint: ${config.env.fingerprint}`);

View File

@ -1,6 +1,6 @@
import express from 'express'; import express from 'express';
import { createServer } from 'http'; import { createServer } from 'http';
import { initIpfs, stopIpfs, initOrbitDB, createServiceLogger, logPeersStatus } from '@debros/network'; // Import from the new package import network, { createServiceLogger, logPeersStatus } from '@debros/network'; // Import from the new package
import mainRouter from '../../routes/api'; import mainRouter from '../../routes/api';
import { applyMiddleware } from './middleware'; import { applyMiddleware } from './middleware';
import { registerHealthEndpoints, startStatusReporting } from './healthService'; import { registerHealthEndpoints, startStatusReporting } from './healthService';
@ -34,10 +34,9 @@ export const startServer = async () => {
anonInstance = anon; anonInstance = anon;
// Initialize IPFS with the new package // Initialize IPFS with the new package
await initIpfs();
// Initialize OrbitDB with the new package // Initialize OrbitDB with the new package
orbitdbInstance = await initOrbitDB(); orbitdbInstance = await network.db.init()
// Create and configure Express app // Create and configure Express app
const app = createApp(); const app = createApp();
@ -103,15 +102,10 @@ function setupShutdownHandler(
clearInterval(intervals.statusReportInterval); clearInterval(intervals.statusReportInterval);
clearInterval(intervals.peerStatusInterval); clearInterval(intervals.peerStatusInterval);
// Stop OrbitDB
serverLogger.info('Stopping OrbitDB...');
await orbitdbInstance.stop();
serverLogger.info('OrbitDB stopped.');
// Stop IPFS // Stop IPFS
serverLogger.info('Stopping IPFS...'); serverLogger.info('Stopping Network...');
await stopIpfs(); await network.db.stop();
serverLogger.info('IPFS stopped.'); serverLogger.info('Network stopped.');
// Stop Anyone // Stop Anyone
if (anonInstance) { if (anonInstance) {

View File

@ -1,4 +1,7 @@
import path from 'path'; import path from 'path';
import dotenv from 'dotenv'
dotenv.config();
export const config = { export const config = {
env: { env: {