Slick is a small chat backend built with Bun, Hono, SQLite, and WebSocket support. It provides auth, workspaces, channels, and real-time message delivery over a simple JSON protocol.
- Bun
- Hono v4
bun:sqlite- Web Crypto JWT
- WebSocket server
- Register and log in users with JWT auth
- Create and list workspaces
- Create and list channels per workspace
- Join channels over WebSocket
- Send and receive real-time channel messages
- Persist users, workspaces, channels, and messages in SQLite
- Bun
- SQLite database file path available to the process
- Install dependencies.
- Set the environment variables you need.
- Start the server.
bun installPORT=3000 DB_PATH=./slick.db JWT_SECRET=change-me bun run src/server.tsIf DB_PATH is not set, the app uses slick.db in the project root.
If JWT_SECRET is not set, the app falls back to a development secret.
bun run dev- start the serverbun run test- run the test suitebun run test:watch- watch testsbun run chat- start the chat app inapps/chat
POST /auth/registerPOST /auth/login
Example body:
{
"username": "alice",
"password": "secret"
}Successful auth returns:
{
"token": "jwt-token"
}GET /workspacesPOST /workspaces
Create workspace body:
{
"name": "Design"
}GET /channels/:workspaceIdPOST /channels/:workspaceId
Create channel body:
{
"name": "general"
}Connect with a JWT token:
/ws?token=JWT_TOKEN
Incoming events:
{ "type": "join", "channelId": "..." }
{ "type": "leave", "channelId": "..." }
{ "type": "message", "channelId": "...", "text": "hello" }Server events:
{ "type": "joined", "channelId": "...", "userId": "...", "username": "..." }
{ "type": "left", "channelId": "...", "userId": "...", "username": "..." }
{ "type": "message", "channelId": "...", "userId": "...", "username": "...", "text": "...", "createdAt": 123 }
{ "type": "error", "message": "..." }The app creates these tables on startup:
usersworkspaceschannelsmessages