https://github.com/mohan-kumar-0/url-shortener
My implementation of roadmap.sh url shortener: https://roadmap.sh/projects/url-shortening-service
https://github.com/mohan-kumar-0/url-shortener
apis backend restful-api roadmaps springboot url-shortener
Last synced: 3 months ago
JSON representation
My implementation of roadmap.sh url shortener: https://roadmap.sh/projects/url-shortening-service
- Host: GitHub
- URL: https://github.com/mohan-kumar-0/url-shortener
- Owner: mohan-kumar-0
- Created: 2024-11-24T16:14:10.000Z (over 1 year ago)
- Default Branch: master
- Last Pushed: 2024-11-24T18:00:57.000Z (over 1 year ago)
- Last Synced: 2025-03-20T05:17:46.067Z (over 1 year ago)
- Topics: apis, backend, restful-api, roadmaps, springboot, url-shortener
- Language: Java
- Homepage: https://roadmap.sh/projects/url-shortening-service
- Size: 13.7 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
```markdown
# URL Shortener Service
My implementation of https://roadmap.sh/projects/url-shortening-service
A simple URL shortener service built with Spring Boot and Maven. This service allows you to shorten URLs, retrieve their stats, and manage them with basic CRUD operations.
## Features
- Shorten a URL
- Retrieve URL stats
- Update or delete a shortened URL
- Increment access count on URL retrieval
## Endpoints
### POST /shorten
Shortens a given URL.
**Request Body**:
```json
{
"url": "https://www.example.com/some/long/url"
}
```
**Response**:
```json
{
"id": "1",
"url": "https://www.example.com/some/long/url",
"shortCode": "abc123",
"createdAt": "2021-09-01T12:00:00Z",
"updatedAt": "2021-09-01T12:00:00Z",
"accessCount": 10
}
```
### GET /shorten/{shortCode}/stats
Returns the stats for a shortened URL.
**Request**:
```plaintext
GET /shorten/abc123/stats
```
**Response**:
```json
{
"id": "1",
"url": "https://www.example.com/some/long/url",
"shortCode": "abc123",
"createdAt": "2021-09-01T12:00:00Z",
"updatedAt": "2021-09-01T12:00:00Z",
"accessCount": 10
}
```
### PUT /shorten/{shortCode}
Update the URL associated with a shortened code.
**Request Body**:
```json
{
"url": "https://www.new-url.com"
}
```
**Response**:
```json
{
"id": "1",
"url": "https://www.new-url.com",
"shortCode": "abc123",
"createdAt": "2021-09-01T12:00:00Z",
"updatedAt": "2021-09-02T12:00:00Z",
"accessCount": 10
}
```
### DELETE /shorten/{shortCode}
Delete the shortened URL.
**Response**:
- `204 No Content` if the URL was successfully deleted.
- `404 Not Found` if the shortened URL does not exist.
## Technologies Used
- Spring Boot
- SQLite
- Maven
## How to Run
1. Clone the repository.
2. Ensure you have Java 11+ installed.
3. Run `mvn spring-boot:run`.
4. The service will be available at `http://localhost:8080`.
## License
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
```