You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
|`/api/ping`| GET | Ping the API to check if it's running | - | HTTP 200 `{"message": "pong"}`|
97
-
|`/:slug`| GET | Retrieve a link by its slug | - | HTTP 301 |
98
-
|`/api/links`| GET | Retrieve all links | - | HTTP 200 `[ { "data": { "id": "84f0c7a4-8c4e-4665-b676-cb9c5e40f1db", "refer": "http://localhost:4000/3wP4BQ", "origin": "https://monocuco.donado.co", "clicks": [ { "id": "730e2202-58f9-478c-a24c-f1c561df6716", "user_agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:127.0) Gecko/20100101 Firefox/127.0", "language": "en-US", "browser": "Firefox", "os": "Mac OS X", "source": "Unknown", "created_at": "2024-07-12T19:25:22Z" } ] } } ]`|
99
-
|`/api/links/:id`| GET | Retrieve a link by its ID | - | HTTP 200 `{ "data": { "id": "84f0c7a4-8c4e-4665-b676-cb9c5e40f1db", "refer": "http://localhost:4000/3wP4BQ", "origin": "https://monocuco.donado.co", "clicks": [ { "id": "730e2202-58f9-478c-a24c-f1c561df6716", "user_agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:127.0) Gecko/20100101 Firefox/127.0", "language": "en-US", "browser": "Firefox", "os": "Mac OS X", "source": "Unknown", "created_at": "2024-07-12T19:25:22Z" } ] } }`|
100
-
|`/api/links`| POST | Create a new link |`{"url": "https://kagi.com"}`| HTTP 200 `{ "data": { "id": "84f0c7a4-8c4e-4665-b676-cb9c5e40f1db", "refer": "http://localhost:4000/3wP4BQ", "origin": "https://kagi.com", "clicks": [] } }`|
101
-
|`/api/links/:id`| PUT | Update an existing link by its ID |`{"url": "https://sjdonado.com"}`| HTTP 200 `{ "data": { "id": "84f0c7a4-8c4e-4665-b676-cb9c5e40f1db", "refer": "http://localhost:4000/3wP4BQ", "origin": "https://sjdonado.com", "clicks": [] } }`|
102
-
|`/api/links/:id`| DELETE | Delete a link by its ID | - | HTTP 204 |
103
-
104
-
**CLI**
90
+
# Usage
91
+
92
+
## API Endpoints
93
+
94
+
1.**Ping the API**
95
+
96
+
-**Endpoint**: `/api/ping`
97
+
-**HTTP Method**: GET
98
+
-**Description**: Ping the API to check if it's running
99
+
-**Payload**: -
100
+
-**Response Example**:
101
+
```json
102
+
{
103
+
"message": "pong"
104
+
}
105
+
```
106
+
107
+
2. **Retrieve a link by its slug**
108
+
109
+
- **Endpoint**: `/:slug`
110
+
- **HTTP Method**: GET
111
+
- **Description**: Retrieve a link by its slug
112
+
- **Payload**: -
113
+
- **Headers**: `X-Api-Key`
114
+
- **Response Example**:
115
+
```json
116
+
{
117
+
"data": {
118
+
"id": "84f0c7a4-8c4e-4665-b676-cb9c5e40f1db",
119
+
"refer": "http://localhost:4000/3wP4BQ",
120
+
"origin": "https://monocuco.donado.co",
121
+
"clicks": [
122
+
{
123
+
"id": "730e2202-58f9-478c-a24c-f1c561df6716",
124
+
"user_agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:127.0) Gecko/20100101 Firefox/127.0",
125
+
"language": "en-US",
126
+
"browser": "Firefox",
127
+
"os": "Mac OS X",
128
+
"source": "Unknown",
129
+
"created_at": "2024-07-12T19:25:22Z"
130
+
}
131
+
]
132
+
}
133
+
}
134
+
```
135
+
136
+
3. **Retrieve all links**
137
+
138
+
- **Endpoint**: `/api/links`
139
+
- **HTTP Method**: GET
140
+
- **Description**: Retrieve all links
141
+
- **Payload**: -
142
+
- **Headers**: `X-Api-Key`
143
+
- **Response Example**:
144
+
```json
145
+
{
146
+
"data": [
147
+
{
148
+
"id": "84f0c7a4-8c4e-4665-b676-cb9c5e40f1db",
149
+
"refer": "http://localhost:4000/3wP4BQ",
150
+
"origin": "https://monocuco.donado.co",
151
+
"clicks": [
152
+
{
153
+
"id": "730e2202-58f9-478c-a24c-f1c561df6716",
154
+
"user_agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:127.0) Gecko/20100101 Firefox/127.0",
155
+
"language": "en-US",
156
+
"browser": "Firefox",
157
+
"os": "Mac OS X",
158
+
"source": "Unknown",
159
+
"created_at": "2024-07-12T19:25:22Z"
160
+
}
161
+
]
162
+
}
163
+
]
164
+
}
165
+
```
166
+
167
+
4. **Retrieve a link by its ID**
168
+
169
+
- **Endpoint**: `/api/links/:id`
170
+
- **HTTP Method**: GET
171
+
- **Description**: Retrieve a link by its ID
172
+
- **Payload**: -
173
+
- **Headers**: `X-Api-Key`
174
+
- **Response Example**:
175
+
```json
176
+
{
177
+
"data": {
178
+
"id": "84f0c7a4-8c4e-4665-b676-cb9c5e40f1db",
179
+
"refer": "http://localhost:4000/3wP4BQ",
180
+
"origin": "https://monocuco.donado.co",
181
+
"clicks": [
182
+
{
183
+
"id": "730e2202-58f9-478c-a24c-f1c561df6716",
184
+
"user_agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:127.0) Gecko/20100101 Firefox/127.0",
185
+
"language": "en-US",
186
+
"browser": "Firefox",
187
+
"os": "Mac OS X",
188
+
"source": "Unknown",
189
+
"created_at": "2024-07-12T19:25:22Z"
190
+
}
191
+
]
192
+
}
193
+
}
194
+
```
195
+
196
+
5. **Create a new link**
197
+
198
+
- **Endpoint**: `/api/links`
199
+
- **HTTP Method**: POST
200
+
- **Description**: Create a new link
201
+
- **Payload**:
202
+
```json
203
+
{
204
+
"url": "https://example.com"
205
+
}
206
+
```
207
+
- **Headers**: `X-Api-Key`
208
+
- **Response Example**:
209
+
```json
210
+
{
211
+
"data": {
212
+
"id": "84f0c7a4-8c4e-4665-b676-cb9c5e40f1db",
213
+
"refer": "http://localhost:4000/3wP4BQ",
214
+
"origin": "https://monocuco.donado.co/test",
215
+
"clicks": []
216
+
}
217
+
}
218
+
```
219
+
220
+
6. **Update an existing link by its ID**
221
+
222
+
- **Endpoint**: `/api/links/:id`
223
+
- **HTTP Method**: PUT
224
+
- **Description**: Update an existing link by its ID
225
+
- **Payload**:
226
+
```json
227
+
{
228
+
"url": "https://newexample.com"
229
+
}
230
+
```
231
+
- **Headers**: `X-Api-Key`
232
+
- **Response Example**:
233
+
```json
234
+
{
235
+
"data": {
236
+
"id": "84f0c7a4-8c4e-4665-b676-cb9c5e40f1db",
237
+
"refer": "http://localhost:4000/3wP4BQ",
238
+
"origin": "https://newexample.com",
239
+
"clicks": []
240
+
}
241
+
}
242
+
```
243
+
244
+
7. **Delete a link by its ID**
245
+
246
+
- **Endpoint**: `/api/links/:id`
247
+
- **HTTP Method**: DELETE
248
+
- **Description**: Delete a link by its ID
249
+
- **Payload**: -
250
+
- **Headers**: `X-Api-Key`
251
+
- **Response Example**:
252
+
```json
253
+
{
254
+
"message": "Link deleted"
255
+
}
256
+
```
257
+
258
+
## CLI
105
259
106
260
```
107
261
Usage: ./cli [options]
@@ -111,9 +265,9 @@ Options:
111
265
--delete-user=USER_ID Delete a user by ID
112
266
```
113
267
114
-
##Development
268
+
# Development
115
269
116
-
**Installation**
270
+
1. **Installation**
117
271
118
272
```bash
119
273
brew tap amberframework/micrate
@@ -125,26 +279,22 @@ shards run migrate
125
279
shards run bit
126
280
```
127
281
128
-
**Generate the `X-Api-Key`**
282
+
2.**Generate the `X-Api-Key`**
129
283
130
284
```bash
131
285
shards run cli -- --create-user=Admin
132
286
```
133
287
134
-
##Run tests
288
+
# Run tests
135
289
136
290
```bash
137
291
ENV=test crystal spec
138
292
```
139
293
140
-
##Contributing
294
+
# Contributing
141
295
142
296
1. Fork it (<https://github.com/sjdonado/bit/fork>)
143
297
2. Create your feature branch (`git checkout -b my-new-feature`)
144
298
3. Commit your changes (`git commit -am 'Add some feature'`)
145
299
4. Push to the branch (`git push origin my-new-feature`)
0 commit comments