Skip to content

Commit 2b11ad5

Browse files
committed
ai: completionId: cgen-c364d2178ba749e49c33b3c4b5d71689
1 parent 6eed62a commit 2b11ad5

File tree

1 file changed

+325
-1
lines changed

1 file changed

+325
-1
lines changed

.builderrules

Lines changed: 325 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,325 @@
1-
Make sure when generating with MUI components look at the examples in src/* for correct usage of this code on the specific MUI versions we use and patterns we want to replicate.
1+
Make sure when generating with MUI components look at the examples in src/* for correct usage of this code on the specific MUI versions we use and patterns we want to replicate.
2+
3+
When doing any thing with user data, use this internal API of ours:
4+
5+
# Users API
6+
7+
A RESTful API for managing user data, built with Cloudflare Workers and D1 database.
8+
9+
## Base URL
10+
11+
```
12+
https://user-api.builder-io.workers.dev/api
13+
```
14+
15+
## Authentication
16+
17+
No authentication required for public endpoints.
18+
19+
## Endpoints
20+
21+
### List Users
22+
23+
Returns a paginated list of users with optional search and sorting capabilities.
24+
25+
```
26+
GET /users
27+
```
28+
29+
#### Query Parameters
30+
31+
| Parameter | Type | Default | Description |
32+
| --------- | ------- | ------------ | -------------------------------------------------------- |
33+
| `page` | integer | 1 | Page number for pagination |
34+
| `perPage` | integer | 10 | Number of results per page |
35+
| `search` | string | - | Search users by first name, last name, email, or city |
36+
| `sortBy` | string | "first_name" | Field to sort results by |
37+
| `span` | string | "week" | Time span view ("week" or "month") - affects page offset |
38+
39+
#### Supported Sort Fields
40+
41+
- `name.first` - Sort by first name
42+
- `name.last` - Sort by last name
43+
- `location.city` - Sort by city
44+
- `location.country` - Sort by country
45+
- `dob.age` - Sort by age
46+
- `registered.date` - Sort by registration date
47+
48+
#### Example Request
49+
50+
```bash
51+
curl "https://user-api.builder-io.workers.dev/api/users?page=1&perPage=20&search=john&sortBy=name.first"
52+
```
53+
54+
#### Example Response
55+
56+
```json
57+
{
58+
"page": 1,
59+
"perPage": 20,
60+
"total": 500,
61+
"span": "week",
62+
"effectivePage": 1,
63+
"data": [
64+
{
65+
"login": {
66+
"uuid": "test-uuid-1",
67+
"username": "testuser1",
68+
"password": "password"
69+
},
70+
"name": {
71+
"title": "Mr",
72+
"first": "John",
73+
"last": "Doe"
74+
},
75+
"gender": "male",
76+
"location": {
77+
"street": {
78+
"number": 123,
79+
"name": "Main St"
80+
},
81+
"city": "New York",
82+
"state": "NY",
83+
"country": "USA",
84+
"postcode": "10001",
85+
"coordinates": {
86+
"latitude": 40.7128,
87+
"longitude": -74.006
88+
},
89+
"timezone": {
90+
"offset": "-05:00",
91+
"description": "Eastern Time"
92+
}
93+
},
94+
"email": "[email protected]",
95+
"dob": {
96+
"date": "1990-01-01",
97+
"age": 34
98+
},
99+
"registered": {
100+
"date": "2020-01-01",
101+
"age": 4
102+
},
103+
"phone": "555-0123",
104+
"cell": "555-0124",
105+
"picture": {
106+
"large": "https://example.com/pic1.jpg",
107+
"medium": "https://example.com/pic1-med.jpg",
108+
"thumbnail": "https://example.com/pic1-thumb.jpg"
109+
},
110+
"nat": "US"
111+
}
112+
]
113+
}
114+
```
115+
116+
### Get User
117+
118+
Retrieve a specific user by UUID, username, or email.
119+
120+
```
121+
GET /users/:id
122+
```
123+
124+
#### Parameters
125+
126+
| Parameter | Type | Description |
127+
| --------- | ------ | ----------------------------- |
128+
| `id` | string | User UUID, username, or email |
129+
130+
#### Example Request
131+
132+
```bash
133+
curl "https://user-api.builder-io.workers.dev/api/users/testuser1"
134+
```
135+
136+
### Create User
137+
138+
Create a new user.
139+
140+
```
141+
POST /users
142+
```
143+
144+
#### Request Body
145+
146+
```json
147+
{
148+
"email": "[email protected]",
149+
"login": {
150+
"username": "newuser",
151+
"password": "securepassword"
152+
},
153+
"name": {
154+
"first": "New",
155+
"last": "User",
156+
"title": "Mr"
157+
},
158+
"gender": "male",
159+
"location": {
160+
"street": {
161+
"number": 456,
162+
"name": "Oak Avenue"
163+
},
164+
"city": "Los Angeles",
165+
"state": "CA",
166+
"country": "USA",
167+
"postcode": "90001"
168+
}
169+
}
170+
```
171+
172+
#### Required Fields
173+
174+
- `email`
175+
- `login.username`
176+
- `name.first`
177+
- `name.last`
178+
179+
#### Example Response
180+
181+
```json
182+
{
183+
"success": true,
184+
"uuid": "generated-uuid-here",
185+
"message": "User created successfully"
186+
}
187+
```
188+
189+
### Update User
190+
191+
Update an existing user's information.
192+
193+
```
194+
PUT /users/:id
195+
```
196+
197+
#### Parameters
198+
199+
| Parameter | Type | Description |
200+
| --------- | ------ | ----------------------------- |
201+
| `id` | string | User UUID, username, or email |
202+
203+
#### Request Body
204+
205+
Include only the fields you want to update:
206+
207+
```json
208+
{
209+
"name": {
210+
"first": "Updated"
211+
},
212+
"location": {
213+
"city": "San Francisco"
214+
}
215+
}
216+
```
217+
218+
#### Example Response
219+
220+
```json
221+
{
222+
"success": true,
223+
"message": "User updated successfully"
224+
}
225+
```
226+
227+
### Delete User
228+
229+
Delete a user from the system.
230+
231+
```
232+
DELETE /users/:id
233+
```
234+
235+
#### Parameters
236+
237+
| Parameter | Type | Description |
238+
| --------- | ------ | ----------------------------- |
239+
| `id` | string | User UUID, username, or email |
240+
241+
#### Example Response
242+
243+
```json
244+
{
245+
"success": true,
246+
"message": "User deleted successfully"
247+
}
248+
```
249+
250+
## Error Handling
251+
252+
All errors return appropriate HTTP status codes with a JSON error response:
253+
254+
```json
255+
{
256+
"error": "Error message here"
257+
}
258+
```
259+
260+
### Common Status Codes
261+
262+
- `200` - Success
263+
- `201` - Created
264+
- `400` - Bad Request
265+
- `404` - Not Found
266+
- `405` - Method Not Allowed
267+
- `500` - Internal Server Error
268+
269+
## CORS
270+
271+
The API supports CORS with the following headers:
272+
273+
- `Access-Control-Allow-Origin: *`
274+
- `Access-Control-Allow-Methods: GET, POST, PUT, DELETE, OPTIONS`
275+
- `Access-Control-Allow-Headers: Content-Type`
276+
277+
## Rate Limiting
278+
279+
No rate limiting is currently implemented.
280+
281+
## Examples
282+
283+
### Search for users named "John"
284+
285+
```bash
286+
curl "https://user-api.builder-io.workers.dev/api/users?search=john"
287+
```
288+
289+
### Get users sorted by age
290+
291+
```bash
292+
curl "https://user-api.builder-io.workers.dev/api/users?sortBy=dob.age"
293+
```
294+
295+
### Get page 2 with 50 results per page
296+
297+
```bash
298+
curl "https://user-api.builder-io.workers.dev/api/users?page=2&perPage=50"
299+
```
300+
301+
### Create a new user
302+
303+
```bash
304+
curl -X POST https://user-api.builder-io.workers.dev/api/users \
305+
-H "Content-Type: application/json" \
306+
-d '{
307+
"email": "[email protected]",
308+
"login": {"username": "janesmith"},
309+
"name": {"first": "Jane", "last": "Smith"}
310+
}'
311+
```
312+
313+
### Update a user's city
314+
315+
```bash
316+
curl -X PUT https://user-api.builder-io.workers.dev/api/users/janesmith \
317+
-H "Content-Type: application/json" \
318+
-d '{"location": {"city": "Boston"}}'
319+
```
320+
321+
### Delete a user
322+
323+
```bash
324+
curl -X DELETE https://user-api.builder-io.workers.dev/api/users/janesmith
325+
```

0 commit comments

Comments
 (0)