Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
app.listen(GRAPHQL_PORT);
// websocket server
const WS_PORT = settings.WS_PORT;
const httpServer = createServer((request, response) => {
response.writeHead(404);
response.end();
});
httpServer.listen(WS_PORT, () => console.log( // eslint-disable-line no-console
`Websocket Server is now running on http://localhost:${WS_PORT}`,
));
// subscription server
const server = new SubscriptionServer( // eslint-disable-line no-unused-vars
{ subscriptionManager },
httpServer,
);
// receive inAppConnected message and save integrationId, customerId in
// connection
server.wsServer.on('connect', (connection) => {
connection.on('message', (message) => {
const parsedMessage = JSON.parse(message.utf8Data);
if (parsedMessage.type === 'inAppConnected') {
connection.inAppData = parsedMessage.value; // eslint-disable-line no-param-reassign
}
});
});
// seed the database
seed()
const WS_PORT = process.env.WS_PORT || 8080;
createApolloServer({
schema: schema,
});
const httpServer = createServer((request, response) => {
response.writeHead(404);
response.end();
});
httpServer.listen(WS_PORT, () => console.log(
`Websocket Server is now running on http://localhost:${WS_PORT}`
));
const server = new SubscriptionServer({ subscriptionManager }, httpServer);
app.listen(GRAPHQL_PORT);
// websocket server
const WS_PORT = settings.WS_PORT;
const httpServer = createServer((request, response) => {
response.writeHead(404);
response.end();
});
httpServer.listen(WS_PORT, () => console.log( // eslint-disable-line no-console
`Websocket Server is now running on http://localhost:${WS_PORT}`,
));
// subscription server
const server = new SubscriptionServer( // eslint-disable-line no-unused-vars
{ subscriptionManager },
httpServer,
);
// receive inAppConnected message and save integrationId, customerId in
// connection
server.wsServer.on('connect', (connection) => {
connection.on('message', (message) => {
const parsedMessage = JSON.parse(message.utf8Data);
if (parsedMessage.type === 'inAppConnected') {
connection.inAppData = parsedMessage.value; // eslint-disable-line no-param-reassign
}
});
});
models.sequelize.sync({ force: false }).then(() => {
const server = app.listen(config.server.port, () => {
console.info(
`🔌 HTTP and Websocket Server running in ${app.get('env')}`
+ ` on port ${config.server.port}`
);
});
// eslint-disable-next-line
new SubscriptionServer({ subscriptionManager }, server);
});
// bodyParser is needed just for POST.
app.use('/api/graphql', bodyParser.json(), graphqlExpress({ schema }))
app.use('/api/graphiql', bodyParser.json(), graphiqlExpress({ endpointURL: '/api/graphql' }))
app.listen(PORT)
const websocketServer = createServer((request, response) => {
response.writeHead(404)
response.end()
})
websocketServer.listen(WS_PORT, () => console.log(
`Websocket Server is now running on http://localhost:${WS_PORT}`
))
const subscriptionsServer = new SubscriptionServer(
{
subscriptionManager: subscriptionManager
},
{
server: websocketServer
}
)
server.listen(port, err => {
if (err) {
throw new Error(err);
}
console.log('Go to http://localhost:4000/graphiql to run queries!');
const ss = new SubscriptionServer(
{
execute,
subscribe,
schema,
onConnect: (connectionParams, webSocket, context) => {
console.log('onConnect');
console.log('connectionParams: ', connectionParams);
return connectionParams;
},
onOperation: (message, params, webSocket) => {
console.log('onOperation');
console.log('params: ', params);
console.log('message: ', message);
return message;
},
onOperationDone: webSocket => {
_startSubscriptionServer (port) {
logger.log(`Websocket Server is now running on ws://localhost:${port}/subscriptions`);
this._subscriptionServer = new SubscriptionServer({
schema: this._schema,
execute,
subscribe
}, {
server: this._httpServer,
path: '/subscriptions',
});
}
}
createServer(
schema: any,
options: ServerOptions = {},
socketOptions: WebSocket.ServerOptions = {},
) {
this.subscriptionServer = new SubscriptionServer(
{ execute, subscribe, schema, ...options },
{
server: this.ws,
path: '/subscriptions',
...socketOptions,
},
);
}
server.listen(PORT, HOST, error => {
if (error) return reject(error)
resolve({
http: server,
ws: new SubscriptionServer(this.getSubscriptionOptions(), {
server,
path: `/${SUBSCRIPTION_PATH}`
})
})
})
})
serverSubscription.listen(GRAPHQL_SUBSCRIPTION_PORT, () => {
log(
'Started graphql-subscription endpoint at http://localhost:' +
GRAPHQL_SUBSCRIPTION_PORT + GRAPHQL_SUBSCRIPTION_PATH
);
const subServer = new SubscriptionServer(
{
execute,
subscribe,
schema,
rootValue: root
},
{
server: serverSubscription,
path: GRAPHQL_SUBSCRIPTION_PATH,
}
);
return subServer;
});