mongodb-livedata-server 0.0.1 → 0.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +7 -1
- package/livedata_server.ts +2 -1
- package/meteor/ddp/livedata_server.ts +4 -3
- package/meteor/ddp/subscription.ts +1 -1
- package/package.json +6 -7
package/README.md
CHANGED
|
@@ -8,12 +8,18 @@ Live data is one of the root concepts of Meteor. Data is served via WebSockets v
|
|
|
8
8
|
|
|
9
9
|
Using Meteor locks you into the Meteor ecosystem, which has some problems (mostly for historical reasons). Using live data as a separate npm package might be preferable in many scenarios. Also, people who are trying to migrate from Meteor, might find this package useful as an intermediate step.
|
|
10
10
|
|
|
11
|
+
### Installation
|
|
12
|
+
|
|
13
|
+
```
|
|
14
|
+
npm i mongodb-livedata-server
|
|
15
|
+
```
|
|
16
|
+
|
|
11
17
|
### Usage
|
|
12
18
|
|
|
13
19
|
As a most common example, this is how you can use livedata with Express.js:
|
|
14
20
|
|
|
15
21
|
```js
|
|
16
|
-
const { DDPServer, LiveCursor, LiveMongoConnection } = require('livedata-server')
|
|
22
|
+
const { DDPServer, LiveCursor, LiveMongoConnection } = require('mongodb-livedata-server')
|
|
17
23
|
const express = require('express')
|
|
18
24
|
const app = express()
|
|
19
25
|
const port = 3000
|
package/livedata_server.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
export { DDPServer } from "./meteor/ddp/livedata_server";
|
|
2
|
+
export { ddpError } from "./meteor/ddp/livedata_server";
|
|
2
3
|
export { LiveMongoConnection } from "./meteor/mongo/live_connection";
|
|
3
|
-
export { LiveCursor } from "./meteor/mongo/live_cursor";
|
|
4
|
+
export { LiveCursor } from "./meteor/mongo/live_cursor";
|
|
@@ -6,9 +6,10 @@ import { parseDDP, stringifyDDP, SUPPORTED_DDP_VERSIONS } from "./utils";
|
|
|
6
6
|
import { makeRpcSeed } from "./random-stream";
|
|
7
7
|
import { clone } from "../ejson/ejson";
|
|
8
8
|
import { Hook } from "../callback-hook/hook";
|
|
9
|
+
import { Subscription } from "./subscription";
|
|
9
10
|
|
|
10
11
|
export const DDP: {
|
|
11
|
-
_CurrentPublicationInvocation:
|
|
12
|
+
_CurrentPublicationInvocation: Subscription,
|
|
12
13
|
_CurrentMethodInvocation: MethodInvocation
|
|
13
14
|
} = {} as any;
|
|
14
15
|
|
|
@@ -289,7 +290,7 @@ export class DDPServer {
|
|
|
289
290
|
* @param {String|Object} name If String, name of the record set. If Object, publications Dictionary of publish functions by name. If `null`, the set has no name, and the record set is automatically sent to all connected clients.
|
|
290
291
|
* @param {Function} func Function called on the server each time a client subscribes. Inside the function, `this` is the publish handler object, described below. If the client passed arguments to `subscribe`, the function is called with the same arguments.
|
|
291
292
|
*/
|
|
292
|
-
publish(name: string | Record<string,
|
|
293
|
+
publish(name: string | Record<string, (this: MethodInvocation, ...args: any[]) => Promise<any>> | null, handler?: (this: MethodInvocation, ...args: any[]) => Promise<any>) {
|
|
293
294
|
var self = this;
|
|
294
295
|
|
|
295
296
|
if (typeof name === "string") {
|
|
@@ -328,7 +329,7 @@ export class DDPServer {
|
|
|
328
329
|
* @memberOf Meteor
|
|
329
330
|
* @importFromPackage meteor
|
|
330
331
|
*/
|
|
331
|
-
methods(methods: Record<string,
|
|
332
|
+
methods(methods: Record<string, (this: MethodInvocation, ...args: any[]) => Promise<any>>) {
|
|
332
333
|
var self = this;
|
|
333
334
|
for (const [name, func] of Object.entries(methods)) {
|
|
334
335
|
if (typeof func !== 'function')
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "mongodb-livedata-server",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.3",
|
|
4
4
|
"description": "MongoDB live data server, extracted from Meteor, Fibers removed and converted to TypeScript",
|
|
5
5
|
"main": "dist/livedata_server.js",
|
|
6
6
|
"types": "livedata_server.ts",
|
|
@@ -11,20 +11,19 @@
|
|
|
11
11
|
"author": "Andrei Markeev",
|
|
12
12
|
"license": "MIT",
|
|
13
13
|
"dependencies": {
|
|
14
|
-
"compression": "^1.7.4",
|
|
15
|
-
"connect": "^3.7.0",
|
|
16
|
-
"cookie-parser": "^1.4.6",
|
|
17
14
|
"double-ended-queue": "^2.1.0-0",
|
|
18
15
|
"mongodb": "^4.11.0",
|
|
19
16
|
"permessage-deflate": "^0.1.7",
|
|
20
|
-
"
|
|
21
|
-
"sockjs": "^0.3.24",
|
|
22
|
-
"useragent": "^2.3.0"
|
|
17
|
+
"sockjs": "^0.3.24"
|
|
23
18
|
},
|
|
24
19
|
"devDependencies": {
|
|
25
20
|
"@types/connect": "^3.4.35",
|
|
26
21
|
"@types/double-ended-queue": "^2.1.1",
|
|
27
22
|
"@types/node": "^18.11.9",
|
|
28
23
|
"@types/sockjs": "^0.3.33"
|
|
24
|
+
},
|
|
25
|
+
"repository": {
|
|
26
|
+
"type": "git",
|
|
27
|
+
"url": "git://github.com/andrei-markeev/mongodb-livedata-server.git"
|
|
29
28
|
}
|
|
30
29
|
}
|