Throw-Me
A url shortener (pretty straight forward)
Made with-
- nextJS
- prisma
- postgresql
- chakra UI
deployed on
- App on vercel
- Database on heroku
Api
Create the url in the db
Send a post
request to https://throw-me.now.sh/api/create/
with body as:
{
"url": "https://google.com/",
"name": "google"
}
Create
with JavaScript ajax
var url = "https://throw-me.now.sh/api/create/";
var xhr = new XMLHttpRequest();
xhr.open("POST", url);
xhr.setRequestHeader("Content-Type", "application/json");
xhr.onreadystatechange = function () {
if (xhr.readyState === 4) {
console.log(xhr.status);
console.log(xhr.responseText);
}};
var data = `{
"url": "https://google.com/",
"name": "google"
}`;
xhr.send(data);
Get the url from the db
Send a post
request to https://throw-me.now.sh/api/get/
with body as:
{
"name": "theName"
}
Get
with JavaScript ajax
var url = "https://throw-me.now.sh/api/get/";
var xhr = new XMLHttpRequest();
xhr.open("POST", url);
xhr.setRequestHeader("Content-Type", "application/json");
xhr.onreadystatechange = function () {
if (xhr.readyState === 4) {
console.log(xhr.status);
console.log(xhr.responseText);
}};
var data = `{
"name": "google"
}
`;
xhr.send(data);
Parameters For The Api
- the url has a limit of 200 characters
- the name has a limit of 20 characters