Backend for sclr.ac URL shortner
Generate 302 redirect to longURL of that shortcode
Request
{
"url": "https://some.long.url/of/long/length"
}
Success Response (status: 201
)
{
"status": "success",
"data": {
"shortCode": "kb24JO7",
"shortLink": "https://sclr.ac/kb24JO7"
}
}
Create new short code url (this will assign a random short code)
Create a new shortcode with the given one Request
{
"url": "https://some.long.url/of/long/length"
}
Success Response (status: 201
)
{
"status": "success",
"data": {
"shortCode": "{shortcode}",
"shortLink": "https://sclr.ac/{shortcode}"
}
}
Get details about a short code
Error Response (status: 400
)
{
"status": "error",
"message": "Invalid short Code, too long!"
}
Error Response (status: 404
)
{
"status": "error",
"message": "Invalid short code. Not found in DB"
}
Success Response (status: 200
)
{
"status": "success",
"data": {
"shortCode": "{shortcode}",
"shortLink": "https://sclr.ac/{shortcode}"
}
}
Setup database, user for this project
create database sclrac;
create user sclrac with encrypted password 'sclrac';
grant all privileges on database sclrac to sclrac;
- id
- shortcode
- longUrl