1.1.0 • Published 5 years ago

webux-socket v1.1.0

Weekly downloads
-
License
SEE LICENSE IN li...
Repository
github
Last release
5 years ago

Webux Socket

This module is a wrapper for socket.io it allows to build automatically the socket resource based on a given directory.

Installation

npm i --save webux-socket

Usage

Currently, I recommend you to check the examples in the examples/ directory,

The configuration

Default for production,

module.exports = {
  baseDir: path.join(__dirname, "..", "api", "v1", "actions"),
  isAuthenticated: require(__dirname, path.join("..", "isAuth.js")),
  accessTokenKey: "accessToken",
  redis: {
    enabled: true,
    mock:
      process.env.REDIS_MOCK && process.env.REDIS_MOCK == "false"
        ? false
        : false,
    host: process.env.REDIS_HOST || "127.0.0.1",
    port: process.env.REDIS_PORT || "6379",
    password: process.env.REDIS_PASSWORD || "password123"
  }
};

The baseDir is the directory that contains the socket actions (the .on)

The isAuthenticated has to be a function, you can do it like the example above, or you can also write the function directly in the configuration file. It must contains the accessTokenValue as the first parameter and a callback for second.

The accessTokenKey is not the VALUE, this is the key name of the cookie, for example the cookie will contain a key/value of 'accessToken':'SOME_JWT_STRING'

The redis object is use to configure redis, it will allow you to run multiple instances/processes of your backend and the socket will be emitted to everyone.

You will not be able to test the cluster mode with the Redis mock implementation.

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

License

SEE LICENSE IN license.txt

1.1.0

5 years ago

1.0.14

5 years ago

1.0.13

5 years ago

1.0.12

5 years ago

1.0.11

5 years ago

1.0.10

5 years ago

1.0.9

5 years ago

1.0.8

5 years ago

1.0.7

5 years ago

1.0.6

5 years ago

1.0.5

5 years ago

1.0.4

5 years ago

1.0.3

5 years ago

1.0.2

5 years ago

1.0.1

5 years ago