1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
|
<!doctype html>
<html>
<head>
<meta charset="utf-8" />
<title>Babbelkes API Documentation</title>
</head>
<body>
<h1>Babbelkes - Chat API</h1>
<p>A simple chat API built with Node.js, Express, and MongoDB.</p>
<h2>Authentication</h2>
<p>Protected endpoints require a Bearer token in the Authorization header:</p>
<code>Authorization: Bearer <token></code>
<p>Get your token by creating a user or logging in.</p>
<h2>Users (Public)</h2>
<ul>
<li><strong>GET</strong> /api/users - List users (query: limit, offset)</li>
<li><strong>GET</strong> /api/users/search?q=term - Search users by username or displayName</li>
<li><strong>GET</strong> /api/users/:id - Get user by ID</li>
<li><strong>POST</strong> /api/users - Create user (body: username, displayName?) - Returns token</li>
<li><strong>POST</strong> /api/users/login - Login (body: username) - Returns token</li>
<li><strong>PUT</strong> /api/users/:id - Update user (body: username?, displayName?)</li>
<li><strong>DELETE</strong> /api/users/:id - Delete user</li>
</ul>
<h2>Rooms (Protected)</h2>
<ul>
<li><strong>GET</strong> /api/rooms - List rooms (query: limit, offset, type, memberId)</li>
<li><strong>GET</strong> /api/rooms/search?q=term - Search rooms by name</li>
<li><strong>GET</strong> /api/rooms/:id - Get room by ID</li>
<li><strong>GET</strong> /api/rooms/:id/messages - Get room chat history (query: limit, offset)</li>
<li><strong>POST</strong> /api/rooms - Create room (body: name?, type?, members?)</li>
<li><strong>PUT</strong> /api/rooms/:id - Update room (body: name?, type?)</li>
<li><strong>POST</strong> /api/rooms/:id/members - Add member (body: userId)</li>
<li><strong>DELETE</strong> /api/rooms/:id/members/:userId - Remove member</li>
<li><strong>DELETE</strong> /api/rooms/:id - Delete room</li>
</ul>
<h2>Messages (Protected)</h2>
<ul>
<li><strong>GET</strong> /api/messages - List messages (query: limit, offset, authorId)</li>
<li><strong>GET</strong> /api/messages/search?q=term - Search messages by text</li>
<li><strong>GET</strong> /api/messages/:id - Get message by ID</li>
<li><strong>POST</strong> /api/messages - Create message (body: authorId, text, roomId?)</li>
<li><strong>PUT</strong> /api/messages/:id - Update message (body: text)</li>
<li><strong>DELETE</strong> /api/messages/:id - Delete message</li>
</ul>
<h2>Validation</h2>
<ul>
<li>Username: 3-30 characters, alphanumeric and underscore only</li>
<li>Display name: max 100 characters</li>
<li>Message text: 1-1000 characters</li>
<li>Room name: max 100 characters</li>
<li>Room type: "group" or "direct"</li>
</ul>
<h2>Pagination</h2>
<p>Use <code>limit</code> and <code>offset</code> query parameters. Default limit: 50, max: 200.</p>
<h2>Storage</h2>
<p>Data is stored in MongoDB.</p>
</body>
</html>
|