A simple yet useful web service to compress long URLs into shorter ones.
- General URL shortening
- Custom URL shortening
- Easy to integrate with other applications
- Shorten given long URL :
POST /api/short
- Shorten URL with custom code :
POST /api/custom
- Redirect to website :
GET /:code
- Check API health :
GET /health
POST /api/short
{
"longUrl": "<the-long-url-to-be-shortened>"
}
{
"_id": "5f81dca70f685f2f104",
"longUrl": "<the-long-url-to-be-shortened>",
"shortUrl": "https://<base-url>/-i8bZ5O9B",
"urlCode": "-i8bZ5O9B",
"date": "Sat Oct 10 2017 21:39:11 GMT+0530 (India Standard Time)",
"__v": 0
}
{
"errors": {
"message": "Invalid long URL"
}
}
{
"errors": {
"message": "Invalid base URL"
}
}
{
"errors": {
"message": "Server error"
}
}
POST /api/custom
{
"longUrl": "<the-long-url-to-be-shortened>",
"urlCode": "<custom-code>"
}
{
"_id": "5f81dca70f685f2f104",
"longUrl": "<the-long-url-to-be-shortened>",
"shortUrl": "https://<base-url>/-i8bZ5O9B",
"urlCode": "-i8bZ5O9B",
"date": "Sat Oct 10 2017 21:39:11 GMT+0530 (India Standard Time)",
"__v": 0
}
{
"errors": {
"message": "Code already in use"
}
}
{
"errors": {
"message": "Invalid long URL"
}
}
{
"errors": {
"message": "Invalid base URL"
}
}
{
"errors": {
"message": "Server error"
}
}
- Clone the repository
- Install node from official website
- Install the dependencies for the project using below command
npm install
- To run the application locally
npm run dev
- In the browser goto : http://localhost:5000/health
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change. Check Contributing.md for more instructions.