https://github.com/timi-leyin/shortner-api
A simple API for shortening and retrieving links.
https://github.com/timi-leyin/shortner-api
expessjs linkshortener nodejs-api
Last synced: 12 months ago
JSON representation
A simple API for shortening and retrieving links.
- Host: GitHub
- URL: https://github.com/timi-leyin/shortner-api
- Owner: Timi-Leyin
- License: mit
- Created: 2024-01-25T14:12:04.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2024-01-25T14:49:09.000Z (over 2 years ago)
- Last Synced: 2025-01-17T15:51:43.449Z (over 1 year ago)
- Topics: expessjs, linkshortener, nodejs-api
- Language: TypeScript
- Homepage:
- Size: 78.1 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Shortner API
A simple API for shortening and retrieving links.
## [Documentation](#docs)
### Routes
- Shorten a Link:
- Endpoint: `/shorten`
- Method: POST
- Example Request using `fetch`:
```javascript
fetch("{{BASEURL}}/shorten", {
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({ url: "https://example.com" }),
})
.then((response) => response.json())
.then((data) => console.log(data))
.catch((error) => console.error("Error:", error));
```
- Example Response:
```json
{
"id": "abc123",
"shortUrl": "{{baseurl}}/abc123",
"expireAt": "12/04/2025"
}
```
- Use Shortened Link:
- Endpoint: `{{BASEURL}}/:id`
- Open the link in your browser
## Getting Started
1. Clone the repository:
```bash
git clone https://github.com/Timi-Leyin/shortner-api.git
```
1. Install dependencies:
```bash
cd shortner-api
npm install
```
1. Start the API:
```bash
npm start
```
The API will be accessible at http://localhost:your-port.
## Contributing
If you'd like to contribute, please fork the repository and create a pull request. Make sure to follow the [Contributing Guidelines.](#)
## License
This project is licensed under the MIT License.