AnzuSystems Notification-Server by Petit Press a.s. (www.sme.sk)
Provides WebSocket functionality among Anzusystems' projects.
Notification Server is a simple WebSocket server which requires only these technologies:
- Google Pub/Sub
- Users externally authenticated with a JWT stored in cookies.
- note: Notification Server only validates token according a public certificated.
Notification Server supports horizontal scaling by creating a Pub/Sub subscription for each running instance.
To send a PubsubMessage you must define following fields:
- attributes.targetSsoUserIds - array of user ids which should receive a message
- attributes.eventName - string of an event name
- data (optional) - any string (e.g. serialized json) which will be sent to target sso user ids
Configure these environment variables:
- SSO_JWT_COOKIES - array of cookies names where is a JWT stored. It might contain only one cookie name, but for security purpose it's recommended to split the token into two parts:
- header and payload into not http-only cookie
- signature into http- only cookie
- SSO_JWT_ALGORITHM - the algorithm used to encrypt a JWT (e.g. ES256)
- PUBSUB_TOPIC - string name of the Pub/Sub topic name.
- APP_INSTANCE_NAME - string name of the instance. If you run Notification Server on multiple instances (e.g. containers), use the unique name of the container. Pub/Sub will create on a startup subscription for each container to a topic defined in PUBSUB_TOPIC.
- WEBSOCKET_SERVER_CORS - regex cors url from which is connection made of
- WEBSOCKET_SERVER_PORT - server port for WebSocket server
- LOG_LEVEL - any value of Winston's logger levels
- GCLOUD_PROJECT - your project name in Google Pub/Sub, or for a development purpose use "emulator-project"
- GOOGLE_APPLICATION_CREDENTIALS - your path to a Google Pub/Sub credentials json, or for a development purpose don't define this env
- PUBSUB_EMULATOR_HOST - only for a development purpose, define a host to an emulator host
Run prod
node server:
bin/run prod
For a development run, read README-DEV.md.