A Socket.io/Express/TypeScript web chat backend. This is a test/practice service, with the associated client available separately.
The list of supported events combined with the list of expected objects are summarised below.
Event | Object |
---|---|
greeting | Greeting |
chatMessage | ChatMessage |
typing | TypingMessage |
userList | UserStatusMessage |
disconnection | UserStatusMessage |
connection | - (no message) |
newUser | BaseMessage |
Depending on your package manager:
echo "ALLOWED_ORIGINS=\"http://localhost:5173\"" > .env
pnpm install
pnpm run dev
echo "ALLOWED_ORIGINS=\"http://localhost:5173\"" > .env
npm install
npm run dev
Each client must make a GET request to /token
prior to opening the socket. The tokens are generated using Node's built-in crypto module.