Skip to content

Commit ef4b447

Browse files
committed
Update README.md
1 parent 9fd4f41 commit ef4b447

File tree

1 file changed

+129
-1
lines changed

1 file changed

+129
-1
lines changed

README.md

Lines changed: 129 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,133 @@
11
# url-shortening-api-netlify-edge-supabase
22

3+
[![Star on GitHub](https://img.shields.io/github/stars/samestrin/url-shortening-api-netlify-edge-supabase?style=social)](https://github.com/samestrin/url-shortening-api-netlify-edge-supabase/stargazers)[![Fork on GitHub](https://img.shields.io/github/forks/samestrin/url-shortening-api-netlify-edge-supabase?style=social)](https://github.com/samestrin/url-shortening-api-netlify-edge-supabase/network/members)[![Watch on GitHub](https://img.shields.io/github/watchers/samestrin/url-shortening-api-netlify-edge-supabase?style=social)](https://github.com/samestrin/url-shortening-api-netlify-edge-supabase/watchers)
4+
5+
![Version 0.0.1](https://img.shields.io/badge/Version-0.0.1-blue)[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)[![Built with Node.js](https://img.shields.io/badge/Built%20with-Node.js-green)](https://nodejs.org/)
6+
37
url-shortening-api-netlify-edge-supabase is a URL shortener service. It is a serverless application that provides URL shortening and retrieval functionalities. Utilizing Netlify Edge Functions and Supabase, a cloud-based database, the application offers a high performance, efficient and scalable solution for creating short URLs that redirect to the original, longer URLs.
48

5-
This replaces the legacy [url-shortening-api-netlify-supabase](https://github.com/samestrin/url-shortening-api-netlify-supabase) project.
9+
This replaces the legacy [url-shortening-api-netlify-edge-supabase](https://github.com/samestrin/url-shortening-api-netlify-edge-supabase) project.
10+
11+
### **Features**
12+
13+
- **URL Shortening**: Convert long URLs into short, manageable links that are easier to share.
14+
- **URL Validation**: Ensures that only valid URLs with proper protocols are processed.
15+
- **Automatic URL Deduplication**: Checks the database to avoid storing duplicate entries for the same URL.
16+
- **High Performance**: Leveraging Netlify Edge Functions combined with the Supabase REST API for high-speed data retrieval and storage.
17+
- **Error Handling**: Robust error handling mechanisms to provide clear feedback on the nature of issues encountered.
18+
19+
## Endpoints
20+
21+
### Shorten URL
22+
23+
**Endpoint:** `/shorten` **Method:** POST
24+
25+
Shorten a long URL and return the shortened URL.
26+
27+
- `url`: The URL to be shortened.
28+
29+
#### **Example Usage**
30+
31+
Use a tool like Postman or curl to make a request:
32+
33+
```bash
34+
curl -X POST \
35+
https://localhost/shorten \
36+
-H 'Content-Type: application/x-www-form-urlencoded' \
37+
--data-urlencode 'url=https://www.google.com'
38+
```
39+
40+
The server responds with:
41+
42+
```bash
43+
{"shortUrl":"lqywv6P"}
44+
```
45+
46+
### Forward URL
47+
48+
**Endpoint:** `/[shortId]` **Method:** GET
49+
50+
Based on shortened URL, e.g. `/lqywv6P` HTTP 301 forward to a long url.
51+
52+
This endpoint is accessed by navigating directly to the shortened URL.
53+
54+
#### **Example Usage**
55+
56+
Use curl to make a request:
57+
58+
```bash
59+
curl http://localhost/[shortId]
60+
```
61+
62+
### Retrieve Latest Shortened Links
63+
64+
**Endpoint:** `/latest` **Method:** GET
65+
66+
Retrieve the latest URLs shortened.
67+
68+
This endpoint is accessed by navigating directly to /latest.
69+
70+
#### **Example Usage**
71+
72+
Use curl to make a request:
73+
74+
```bash
75+
curl http://localhost/latest
76+
```
77+
78+
### Retrieve Count
79+
80+
**Endpoint:** `/count` **Method:** GET
81+
82+
Retrieve the number of URLs shortened.
83+
84+
This endpoint is accessed by navigating directly to /count.
85+
86+
#### **Example Usage**
87+
88+
Use curl to make a request:
89+
90+
```bash
91+
curl http://localhost/count
92+
```
93+
94+
### Retrieve Version
95+
96+
**Endpoint:** `/version` **Method:** GET
97+
98+
Retrieve the current version of the API.
99+
100+
This endpoint is accessed by navigating directly to /version.
101+
102+
#### **Example Usage**
103+
104+
Use curl to make a request:
105+
106+
```bash
107+
curl http://localhost/version
108+
```
109+
110+
## CORS
111+
112+
The server responds with appropriate CORS headers such as Access-Control-Allow-Origin.
113+
114+
## Error Handling
115+
116+
The API handles errors gracefully and returns appropriate error responses:
117+
118+
- **400 Bad Request**: Invalid request parameters.
119+
- **404 Not Found**: Resource not found.
120+
- **405 Method Not Allowed**: Invalid request method (not GET or POST).
121+
- **500 Internal Server Error**: Unexpected server error.
122+
123+
## Contribute
124+
125+
Contributions to this project are welcome. Please fork the repository and submit a pull request with your changes or improvements.
126+
127+
## License
128+
129+
This project is licensed under the MIT License - see the LICENSE file for details.
130+
131+
## Share
132+
133+
[![Twitter](https://img.shields.io/badge/X-Tweet-blue)](https://twitter.com/intent/tweet?text=Check%20out%20this%20awesome%20project!&url=https://github.com/samestrin/url-shortening-api-netlify-edge-supabase) [![Facebook](https://img.shields.io/badge/Facebook-Share-blue)](https://www.facebook.com/sharer/sharer.php?u=https://github.com/samestrin/url-shortening-api-netlify-edge-supabase) [![LinkedIn](https://img.shields.io/badge/LinkedIn-Share-blue)](https://www.linkedin.com/sharing/share-offsite/?url=https://github.com/samestrin/url-shortening-api-netlify-edge-supabase)

0 commit comments

Comments
 (0)