🔗 https://linklite.onrender.com
LinkLite is a URL shortener that allows you to easily create short links to share with others.
It provides a RESTful API that supports the following HTTP methods:
HTTP Type | API Endpoint | Description |
---|---|---|
POST | /api/shorten | Generate a short URL for a long URL |
GET | /api/check/<short_url_id> | Retrieve information about a short URL |
GET | /<short_url_id> | Redirect to the long URL for a given <short_url_id> |
The response will include the short URL and the expiration date in ISO format(UTC +0).
The expiration date is set to 180 days from the time the short URL is generated.
curl -X POST -H "Content-Type:application/json" https://linklite.onrender.com/api/shorten -d '{
"url": "<long_url>"
}'
# response
{
"shortUrl": "https://linklite.onrender.com/<short_url_id>",
"expireAt": "YYYY-MM-DDTHH:mm:ssZ"
}
The response will include the long URL, the short URL, and the expiration date.
curl -L -X GET https://linklite.onrender.com/api/check/<short_url_id>
# response
{
"longUrl": "<long_url>",
"shortUrl": "https://linklite.onrender.com/<short_url_id>",
"expireAt": "YYYY-MM-DDTHH:mm:ssZ"
}
Simply enter the shout URL in the web browser or send a GET request using curl
.
curl -L -X GET https://linklite.onrender.com/<short_url_id>
To run this application, you can follow the steps below:
git clone [email protected]:james5418/LinkLite.git
cd LinkLite
Create a .env
file in the root of the project and set the environment variables. Here's an example:
PORT=8000
HOST=http://localhost
MONGODB_URI=mongodb://localhost:27017
REDIS_URL=redis://localhost:6379
npm install
npm run build
npm start
docker-compose up -d --build
The API will be available at http://localhost
(port 80).