-
Notifications
You must be signed in to change notification settings - Fork 3.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(ws): Mount Socket.io Admin UI #5435
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,9 @@ | ||
const nr = require('newrelic'); | ||
import { Server, Socket } from 'socket.io'; | ||
import { JwtService } from '@nestjs/jwt'; | ||
import { OnGatewayConnection, OnGatewayDisconnect, WebSocketGateway, WebSocketServer } from '@nestjs/websockets'; | ||
import { Logger } from '@nestjs/common'; | ||
import { instrument } from '@socket.io/admin-ui'; | ||
|
||
import { ISubscriberJwt, ObservabilityBackgroundTransactionEnum } from '@novu/shared'; | ||
import { IDestroy } from '@novu/application-generic'; | ||
|
@@ -18,7 +19,7 @@ | |
constructor(private jwtService: JwtService, private subscriberOnlineService: SubscriberOnlineService) {} | ||
|
||
@WebSocketServer() | ||
server: Server | null; | ||
server: Server; | ||
|
||
async handleDisconnect(connection: Socket) { | ||
Logger.log(`New disconnect received from ${connection.id}`, LOG_CONTEXT); | ||
|
@@ -199,4 +200,19 @@ | |
this.isShutdown = true; | ||
await this.gracefulShutdown(); | ||
} | ||
|
||
afterInit() { | ||
if (!!process.env.SOCKET_IO_ADMIN_USERNAME && !!process.env.SOCKET_IO_ADMIN_PASSWORD_HASH) { | ||
// For more information on how to use the admin UI, see https://socket.io/docs/v4/admin-ui/ | ||
instrument(this.server, { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ✏ suggestion: Could we add a URL link to the configuration options for Socket.io? I find it useful to have a URL to click on to easily find the other options in case of maintenance + debugging. Specifically, I would like to know what effect the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do you mean as a comment? If yes, done! There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Perfect! 🚀 |
||
auth: { | ||
type: 'basic', | ||
username: process.env.SOCKET_IO_ADMIN_USERNAME, | ||
password: process.env.SOCKET_IO_ADMIN_PASSWORD_HASH, | ||
}, | ||
mode: process.env.NODE_ENV === 'production' ? 'production' : 'development', | ||
namespaceName: '/admin', | ||
}); | ||
} | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👏 praise: Nice tidy up 🧹