Web Socket server written in Node.js (using socket.io) for the MLP Vector Club's website
$ sudo npm install -g pm2
$ pnpm install
$ pnpm run build
$ cp .env.example .env # then fill in the values
$ pm2 start pm2.json
- Winterchilla's visitors are recognized by the
accesscookie, which is looked up in thesessionstable of the database (DB_NAME,mlpvc-rrunless set). - Luna's front end (Celestia) sends a one time token when it connects (
auth: { token }, from Luna'sPOST /users/me/socket-token), andLUNA_URLis where the server asks Luna who it belongs to (POST /internal/websocket/validate, authorized withWS_SERVER_KEY). WithoutLUNA_URLsuch sockets are guests. - The
originof every browser has to matchORIGIN_REGEX, e.g.^https://(next\.)?mlpvector\.club$for both front ends.
POST /notify with Authorization: Bearer <WS_SERVER_KEY> and {"user": "<id>"} makes the server send that user's open browsers the current unread count
(notif-cnt), which is what makes them look at their notifications again. Luna does this whenever a notification is sent or read (WS_SERVER_URL of Luna points
here, http://127.0.0.1:3672); nginx must not expose it (setup/nginx.conf).