sipher/src/server.ts
Nixyan c587737f38 feat: enhance federation key rotation and server discovery functionality
- Added new environment variables for MinIO configuration in .env.local.example.
- Updated package.json and bun.lock to include new dependencies for key management and encryption.
- Refactored server and route handling to support Ed25519 and X25519 key pairs for improved security during key rotation.
- Implemented validation for public keys and enhanced error handling in the discovery routes.
- Introduced new challenges for key rotation, ensuring secure communication between federations.
- Updated README with additional instructions for the new key rotation process.
2026-03-12 18:42:52 -03:00

30 lines
No EOL
851 B
TypeScript

import { config } from 'dotenv'
import { createServer, type IncomingMessage, type ServerResponse } from 'http'
import next from 'next'
import { Server } from 'socket.io'
config({ path: '.env.local' })
const port = parseInt(process.env.PORT || '3000', 10)
const dev = process.env.NODE_ENV !== 'production'
const app = next({ dev })
const handle = app.getRequestHandler()
app.prepare().then(async () => {
const server = createServer(async (req: IncomingMessage, res: ServerResponse) => {
handle(req, res)
})
const io = new Server(server)
io.on('connection', (socket) => {
socket.on('join-firehose', () => socket.join('firehose'))
socket.on('leave-firehose', () => socket.leave('firehose'))
})
server.listen(port)
console.log(
`> Server listening at http://localhost:${port} as ${dev ? 'development' : process.env.NODE_ENV
}`
)
})