Repository navigation
feat(new-webui): Add Fastify plugin for real-time MongoDB query service with Socket.IO. #880
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
Changes from 34 commits
14c1b46
a16c7db
56b1bf9
dd08d56
a4e9f0f
1b29ad2
e30e019
e37d2d2
655024b
2945389
e64a375
cc24dd2
98643f0
61fb259
8626745
738f4a4
f8d58b6
e1f3f55
d9e409e
5dc6052
c7c49ba
fdf6286
440e459
24d2bdc
d56bd8a
a0377cf
9324170
fcf11d7
72dd825
3133b09
1562c3f
d13f0b7
672f9a7
e590394
297b2fc
8324ed5
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
|
Member
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. linking #822 here as a future action item (just as a note; we will refactor this with npm workspaces in a separate PR) |
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,84 @@ | ||||||||||||||||||||||
| /** | ||||||||||||||||||||||
| * Unique ID for each active unique query. Multiple clients can subscribe to the same ID if the | ||||||||||||||||||||||
| * queries are identical. The ID is also used to represent the socket room, and MongoDB | ||||||||||||||||||||||
| * change stream. | ||||||||||||||||||||||
| */ | ||||||||||||||||||||||
| type QueryId = number; | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| /** | ||||||||||||||||||||||
| * Error response to event. | ||||||||||||||||||||||
| */ | ||||||||||||||||||||||
| interface Err { | ||||||||||||||||||||||
| error: string; | ||||||||||||||||||||||
| queryId?: QueryId; | ||||||||||||||||||||||
| } | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| /** | ||||||||||||||||||||||
| * Success response to event. | ||||||||||||||||||||||
| */ | ||||||||||||||||||||||
| interface Success<T> { | ||||||||||||||||||||||
| data: T; | ||||||||||||||||||||||
| } | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| /** | ||||||||||||||||||||||
| * Event response. | ||||||||||||||||||||||
| */ | ||||||||||||||||||||||
| type Response<T> = Err | Success<T>; | ||||||||||||||||||||||
|
davemarco marked this conversation as resolved.
Resolved
|
||||||||||||||||||||||
|
|
||||||||||||||||||||||
|
|
||||||||||||||||||||||
| /** | ||||||||||||||||||||||
| * Events that the client can emit to the server. | ||||||||||||||||||||||
| */ | ||||||||||||||||||||||
| type ClientToServerEvents = { | ||||||||||||||||||||||
| "disconnect": () => void; | ||||||||||||||||||||||
| "collection::init": ( | ||||||||||||||||||||||
| requestArgs: { | ||||||||||||||||||||||
| collectionName: string; | ||||||||||||||||||||||
| }, | ||||||||||||||||||||||
| callback: (res: Response<void>) => void | ||||||||||||||||||||||
| ) => void; | ||||||||||||||||||||||
| "collection::find::subscribe": ( | ||||||||||||||||||||||
| requestArgs: { | ||||||||||||||||||||||
| query: object; | ||||||||||||||||||||||
| options: object; | ||||||||||||||||||||||
| }, | ||||||||||||||||||||||
| callback: (res: Response<{queryId: QueryId; initialDocuments: object[]}>) => void) => void; | ||||||||||||||||||||||
|
Comment on lines
+41
to
+45
Contributor
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. 🧹 Nitpick (assertive) Use
- requestArgs: {
- query: object;
- options: object;
+ requestArgs: {
+ query: Record<string, unknown>;
+ options: Record<string, unknown>;📝 Committable suggestion
Suggested change
|
||||||||||||||||||||||
| "collection::find::unsubscribe": ( | ||||||||||||||||||||||
| requestArgs: { | ||||||||||||||||||||||
| queryId: QueryId; | ||||||||||||||||||||||
| } | ||||||||||||||||||||||
| ) => Promise<void>; | ||||||||||||||||||||||
| }; | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| /** | ||||||||||||||||||||||
| * Events that the server can emit to the client. | ||||||||||||||||||||||
| */ | ||||||||||||||||||||||
| interface ServerToClientEvents { | ||||||||||||||||||||||
| "collection::find::update": (respArgs: { | ||||||||||||||||||||||
| queryId: QueryId; | ||||||||||||||||||||||
| data: object[]; | ||||||||||||||||||||||
| }) => void; | ||||||||||||||||||||||
| } | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| /** | ||||||||||||||||||||||
| * Empty but required by Socket IO. | ||||||||||||||||||||||
| */ | ||||||||||||||||||||||
| interface InterServerEvents { | ||||||||||||||||||||||
| } | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
|
davemarco marked this conversation as resolved.
Resolved
|
||||||||||||||||||||||
| /** | ||||||||||||||||||||||
| * Collection associated with each socket connection. | ||||||||||||||||||||||
| */ | ||||||||||||||||||||||
| interface SocketData { | ||||||||||||||||||||||
| collectionName?: string; | ||||||||||||||||||||||
| } | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| export { | ||||||||||||||||||||||
| ClientToServerEvents, | ||||||||||||||||||||||
| Err, | ||||||||||||||||||||||
| InterServerEvents, | ||||||||||||||||||||||
| Response, | ||||||||||||||||||||||
| ServerToClientEvents, | ||||||||||||||||||||||
| SocketData, | ||||||||||||||||||||||
| QueryId | ||||||||||||||||||||||
| }; | ||||||||||||||||||||||
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.
adding @haiqi96 here since the package scripts are changed
Uh oh!
There was an error while loading. Please reload this page.
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.
@haiqi96 , we added an issue to remove this change in the future. But I did test that it works.
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.
it's not elegant but I don't think it's really an issue.