-
Notifications
You must be signed in to change notification settings - Fork 92
feat(new-webui): Add client library for real-time MongoDB updates. #892
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 all commits
6e372ed
712bd99
f5dd06c
ee3ffb7
39e44cf
e3c3ce7
11a1288
d83db22
8e3c034
32289d1
3fa5132
1e35e7f
6834f5f
80e47c5
72be24f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,50 @@ | ||||||||||||||||||||||
| import { | ||||||||||||||||||||||
| ClientToServerEvents, | ||||||||||||||||||||||
| ServerToClientEvents, | ||||||||||||||||||||||
| } from "@common/index.js"; | ||||||||||||||||||||||
| import {Socket} from "socket.io-client"; | ||||||||||||||||||||||
|
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) Prefer type-only import for Socket -import {Socket} from "socket.io-client";
+import type {Socket} from "socket.io-client";📝 Committable suggestion
Suggested change
|
||||||||||||||||||||||
|
|
||||||||||||||||||||||
| import {MongoCursorSocket} from "./MongoCursorSocket.js"; | ||||||||||||||||||||||
| import {getSharedSocket} from "./SocketSingleton.js"; | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
|
|
||||||||||||||||||||||
| /** | ||||||||||||||||||||||
| * Socket connection to a MongoDB collection residing on a server. Class provides methods to | ||||||||||||||||||||||
| * query the collection. | ||||||||||||||||||||||
| */ | ||||||||||||||||||||||
| class MongoCollectionSocket { | ||||||||||||||||||||||
| #collectionName: string; | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| #socket: Socket<ServerToClientEvents, ClientToServerEvents>; | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| /** | ||||||||||||||||||||||
| * Initalizes socket connection to a MongoDB collection on the server. | ||||||||||||||||||||||
| * | ||||||||||||||||||||||
| * @param collectionName | ||||||||||||||||||||||
| */ | ||||||||||||||||||||||
|
Comment on lines
+20
to
+24
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) Fix typo and clarify JSDoc in constructor - * Initalizes socket connection to a MongoDB collection on the server.
+ * Initializes the shared socket connection for a MongoDB collection on the server.
+ *
+ * @param collectionName - The name of the MongoDB collection to subscribe to.📝 Committable suggestion
Suggested change
|
||||||||||||||||||||||
| constructor (collectionName: string) { | ||||||||||||||||||||||
| this.#socket = getSharedSocket(); | ||||||||||||||||||||||
| this.#collectionName = collectionName; | ||||||||||||||||||||||
| console.log(`MongoDB collection:${collectionName} initialized.`); | ||||||||||||||||||||||
| } | ||||||||||||||||||||||
|
Comment on lines
+25
to
+29
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) Replace console.log with proper logger |
||||||||||||||||||||||
|
|
||||||||||||||||||||||
| /** | ||||||||||||||||||||||
| * Selects documents in collection and returns a cursor-like object. | ||||||||||||||||||||||
| * | ||||||||||||||||||||||
| * @param query | ||||||||||||||||||||||
| * @param options | ||||||||||||||||||||||
| * @return a `MongoCursorSocket`. | ||||||||||||||||||||||
| */ | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| find (query: object, options: object) { | ||||||||||||||||||||||
| return new MongoCursorSocket( | ||||||||||||||||||||||
| this.#socket, | ||||||||||||||||||||||
| this.#collectionName, | ||||||||||||||||||||||
| query, | ||||||||||||||||||||||
| options, | ||||||||||||||||||||||
| ); | ||||||||||||||||||||||
| } | ||||||||||||||||||||||
| } | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
|
|
||||||||||||||||||||||
| export default MongoCollectionSocket; | ||||||||||||||||||||||
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.
🧹 Nitpick (assertive)
Relocate
vite-tsconfig-pathsto devDependencies.The
vite-tsconfig-pathsplugin is only needed at build time and for local development. Moving it todevDependencieswill reduce production install size and clarify its usage scope.