@eleven-am/pondsocket 0.1.7 → 0.1.8

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 CHANGED
@@ -19,13 +19,11 @@ Multiple endpoints can be created but every endpoint is independent of the other
19
19
 
20
20
  ```js
21
21
  import { PondSocket } from "@eleven-am/pondsocket";
22
- import parse from "url";
23
22
 
24
23
  const pond = new PondSocket();
25
24
 
26
25
  const endpoint = pond.createEndpoint('/api/socket', (req, res, _endpoint) => {
27
- const { query } = parse(req.url || '');
28
- const { token } = query;
26
+ const token = req.query.token;
29
27
  if (!token)
30
28
  return res.reject('No token provided');
31
29
  res.accept({
@@ -69,7 +67,7 @@ It can be anything from a boolean to an instance of a class. This data cannot be
69
67
 
70
68
  ```js
71
69
  channel.on('hello', (req, res, channel) => {
72
- const users = channel.getPresence();
70
+ const users = channel.presence;
73
71
  res.assign({
74
72
  assign: {
75
73
  pingDate: new Date(),
@@ -91,7 +89,7 @@ In case there is no *on* function, the message will be sent without any action b
91
89
  ```js
92
90
  import { PondClient } from "@eleven-am/pondsocket/client";
93
91
 
94
- export const socket = new PondClientSocket('/api/socket', {});
92
+ export const socket = new PondClient('/api/socket', {});
95
93
  socket.connect();
96
94
  ```
97
95
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eleven-am/pondsocket",
3
- "version": "0.1.7",
3
+ "version": "0.1.8",
4
4
  "description": "PondSocket is a fast simple socket server",
5
5
  "keywords": [
6
6
  "socket",
@@ -1,4 +1,4 @@
1
- import {BaseClass, default_t, PondDocument, Subscription} from "../pondBase";
1
+ import {default_t, Subscription} from "../pondBase";
2
2
  import {NewUser, PondAssigns, PondChannelData, PondMessage, PondPresence, ServerMessage} from "./types";
3
3
  import {PondSenders, ServerActions} from "./enums";
4
4
  import {ChannelHandler} from "./channelMiddleWare";
@@ -10,12 +10,7 @@ export interface ChannelInfo {
10
10
  assigns: PondPresence[];
11
11
  }
12
12
 
13
- export interface PondUser {
14
- presence: PondDocument<PondPresence>;
15
- assigns: PondDocument<PondAssigns>;
16
- }
17
-
18
- export declare class Channel extends BaseClass {
13
+ export declare class Channel {
19
14
  readonly name: string;
20
15
 
21
16
  /**
@@ -13,6 +13,7 @@ export declare type ChannelEvent = {
13
13
  payload: default_t;
14
14
  event: string;
15
15
  };
16
+
16
17
  export declare type IncomingMiddlewareRequest = {
17
18
  channelName: string;
18
19
  event: string;
@@ -23,4 +24,5 @@ export declare type IncomingMiddlewareRequest = {
23
24
  clientPresence: PondPresence;
24
25
  };
25
26
  };
27
+
26
28
  export declare type ChannelHandler = (req: IncomingMiddlewareRequest, res: PondResponse, channel: Channel) => void | Promise<void>;
@@ -5,14 +5,14 @@ import {IncomingConnection} from "./types";
5
5
  import internal from "stream";
6
6
  import {WebSocket, WebSocketServer} from "ws";
7
7
  import {IncomingMessage} from "http";
8
- import {BaseClass, default_t, PondPath, Resolver, ResponsePicker} from "../pondBase";
8
+ import {default_t, PondPath, Resolver, ResponsePicker} from "../pondBase";
9
9
  import {PondChannel, PondChannelHandler} from "./pondChannel";
10
10
  import {ChannelInfo} from "./channel";
11
11
  import {PondResponse} from "./pondResponse";
12
12
 
13
13
  export declare type EndpointHandler = (req: IncomingConnection, res: PondResponse<ResponsePicker.POND>, endpoint: Endpoint) => void;
14
14
 
15
- export declare class Endpoint extends BaseClass {
15
+ export declare class Endpoint {
16
16
  constructor(server: WebSocketServer, handler: EndpointHandler);
17
17
 
18
18
  /**
@@ -1,11 +1,11 @@
1
- import {BaseClass, default_t, PondPath} from "../pondBase";
1
+ import {default_t, PondPath} from "../pondBase";
2
2
  import {Channel, ChannelInfo} from "./channel";
3
3
  import {IncomingChannelMessage, IncomingJoinMessage, PondMessage, PondResponseAssigns, SocketCache} from "./types";
4
4
  import {PondResponse} from "./pondResponse";
5
5
 
6
6
  export declare type PondChannelHandler = (req: IncomingJoinMessage, res: PondResponse, channel: Channel) => void;
7
7
 
8
- export declare class PondChannel extends BaseClass {
8
+ export declare class PondChannel {
9
9
 
10
10
  /**
11
11
  * @desc Gets a list of all the channels in the endpoint.
@@ -3,12 +3,12 @@
3
3
  /// <reference types="node" />
4
4
  import {IncomingMessage, Server as HTTPServer} from "http";
5
5
  import {WebSocketServer} from "ws";
6
- import {BaseClass, PondPath} from "../pondBase";
6
+ import {PondPath} from "../pondBase";
7
7
  import {Endpoint, EndpointHandler} from "./endpoint";
8
8
  import internal from "stream";
9
9
  import {NextFunction} from "./socketMiddleWare";
10
10
 
11
- export declare class PondSocket extends BaseClass {
11
+ export declare class PondSocket {
12
12
 
13
13
  constructor(server?: HTTPServer, socketServer?: WebSocketServer);
14
14