Odoo GraphQL Subscription using Node, Express JS for Sample
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

31 lines
735 B

const express = require('express');
const { WebSocketServer } = require('ws');
const path = require('path');
const { subscribeToSomething, setWsClient } = require('./subscriptionClient');
const app = express();
const PORT = 4000;
// Serve the HTML file
app.get('/', (req, res) => {
res.sendFile(path.join(__dirname, 'index.html'));
});
const server = app.listen(PORT, () => {
console.log(`Server is running on http://localhost:${PORT}`);
});
// Create WebSocket server
const wss = new WebSocketServer({ server });
wss.on('connection', (ws) => {
console.log('Client connected');
setWsClient(ws);
ws.on('close', () => {
console.log('Client disconnected');
});
});
// Start the subscription
subscribeToSomething();