Skip to content

Commit 36a06ac

Browse files
authored
chore: update README v1.1.0
1 parent 772897c commit 36a06ac

File tree

1 file changed

+176
-26
lines changed

1 file changed

+176
-26
lines changed

README.md

Lines changed: 176 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
[![Docker Stars](https://img.shields.io/docker/stars/sjdonado/bit.svg)](https://hub.docker.com/repository/docker/sjdonado/bit/general)
33
[![Docker Image Size](https://img.shields.io/docker/image-size/sjdonado/bit/latest)](https://hub.docker.com/repository/docker/sjdonado/bit/general)
44

5-
## Benchmark
5+
# Benchmark
66

77
```shell
88
$ ./benchmark.sh
@@ -37,7 +37,7 @@ Average CPU Usage: 0%
3737
Average Response Time: 12.37 µs
3838
```
3939

40-
## Self-hosted
40+
# Self-hosted
4141

4242
- Run via docker-compose
4343

@@ -87,21 +87,175 @@ dokku run bit migrate
8787
dokku run bit cli --create-user=Admin
8888
```
8989

90-
## Usage
91-
92-
**REST API**
93-
94-
| Endpoint | HTTP Method | Description | Payload | Response Example |
95-
| ---------------- | ----------- | ------------------------------------- | --------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
96-
| `/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
105259

106260
```
107261
Usage: ./cli [options]
@@ -111,9 +265,9 @@ Options:
111265
--delete-user=USER_ID Delete a user by ID
112266
```
113267
114-
## Development
268+
# Development
115269
116-
**Installation**
270+
1. **Installation**
117271
118272
```bash
119273
brew tap amberframework/micrate
@@ -125,26 +279,22 @@ shards run migrate
125279
shards run bit
126280
```
127281

128-
**Generate the `X-Api-Key`**
282+
2. **Generate the `X-Api-Key`**
129283

130284
```bash
131285
shards run cli -- --create-user=Admin
132286
```
133287

134-
## Run tests
288+
# Run tests
135289

136290
```bash
137291
ENV=test crystal spec
138292
```
139293

140-
## Contributing
294+
# Contributing
141295

142296
1. Fork it (<https://github.com/sjdonado/bit/fork>)
143297
2. Create your feature branch (`git checkout -b my-new-feature`)
144298
3. Commit your changes (`git commit -am 'Add some feature'`)
145299
4. Push to the branch (`git push origin my-new-feature`)
146300
5. Create a new Pull Request
147-
148-
## Contributors
149-
150-
-

0 commit comments

Comments
 (0)