Apply Composer changes: comprehensive API updates, migrations, middleware, and infrastructure improvements
- Add comprehensive database migrations (001-024) for schema evolution - Enhance API schema with expanded type definitions and resolvers - Add new middleware: audit logging, rate limiting, MFA enforcement, security, tenant auth - Implement new services: AI optimization, billing, blockchain, compliance, marketplace - Add adapter layer for cloud integrations (Cloudflare, Kubernetes, Proxmox, storage) - Update Crossplane provider with enhanced VM management capabilities - Add comprehensive test suite for API endpoints and services - Update frontend components with improved GraphQL subscriptions and real-time updates - Enhance security configurations and headers (CSP, CORS, etc.) - Update documentation and configuration files - Add new CI/CD workflows and validation scripts - Implement design system improvements and UI enhancements
This commit is contained in:
@@ -0,0 +1,61 @@
|
||||
/**
|
||||
* WebSocket server for GraphQL subscriptions
|
||||
*/
|
||||
|
||||
import { WebSocketServer } from 'ws'
|
||||
import { useServer } from 'graphql-ws/lib/use/ws'
|
||||
import { schema } from '../schema'
|
||||
import { createContext } from '../context'
|
||||
import { FastifyRequest } from 'fastify'
|
||||
|
||||
export function createWebSocketServer(httpServer: any, path: string) {
|
||||
const wss = new WebSocketServer({
|
||||
server: httpServer,
|
||||
path,
|
||||
})
|
||||
|
||||
const serverCleanup = useServer(
|
||||
{
|
||||
schema,
|
||||
context: async (ctx) => {
|
||||
// Create a mock request for context
|
||||
const request = {
|
||||
headers: ctx.connectionParams?.authorization
|
||||
? { authorization: ctx.connectionParams.authorization as string }
|
||||
: {},
|
||||
} as FastifyRequest
|
||||
|
||||
return createContext(request)
|
||||
},
|
||||
onConnect: async (ctx) => {
|
||||
// Validate connection - check authentication if needed
|
||||
// For now, allow all connections
|
||||
return true
|
||||
},
|
||||
onDisconnect: (ctx, code, reason) => {
|
||||
// Handle disconnection
|
||||
logger.info('WebSocket client disconnected', { code, reason })
|
||||
},
|
||||
onError: (ctx, msg, errors) => {
|
||||
logger.error('WebSocket error', { message: msg, errors })
|
||||
},
|
||||
},
|
||||
wss
|
||||
)
|
||||
|
||||
// Graceful shutdown
|
||||
const shutdown = () => {
|
||||
serverCleanup.dispose()
|
||||
wss.close()
|
||||
}
|
||||
|
||||
process.on('SIGTERM', shutdown)
|
||||
process.on('SIGINT', shutdown)
|
||||
|
||||
return {
|
||||
wss,
|
||||
serverCleanup,
|
||||
shutdown,
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user