To get a copy of this project up and running on your local machine for testing and development, you would need to have a minimum of the listed prerequisites installed on your local machine. To get a head start.
You must have
-
Node.js (v8.12.0 or higher) and npm (6.4.1 or higher) installed on your local machine. Run
node -v
andnpm -v
in your terminal to confirm that you have them installed -
GIT bash
To get started, clone this repository on your local machine using the following steps:
Launch your terminal and navigate to the folder you want the project to be and enter the the following commands:
$ git clone -b main https://github.com/blty-url-shortener
$ cd blty-url-shortener
$ npm install
Create a .env
file and add the environment variables described in the .env.sample file.
npm run dev
npm test
npm start
The bity-url-shortener a Playgrounds interface at /graphiql
. The query accept one required argument and two optional parameter,
-
url - required
: The url to be converted to a short url -
customName - optional
: A 6-character name provided to be used to form a short url in place of a generated random string -
replace - optional
: This can used if a custom name used to generate a short url exist. It is a boolean value which represent if an existing long url should be replace with the new one
query {
urlShortener(url: "https://replit.com/@Aijeyomah/ZealousWetParameter#index.js") {
status
message
shortUrl
}
}
{
"data": {
"urlShortener": {
"status": 200,
"message": "Successfully shortened url",
"shortUrl": "https://blty.herokuapp.com/PdrTKk"
}
}
}
query {
urlShortener(url: "https://replit.com/@Aijeyomah/ZealousWetParameter#index.js", customName: "enyata") {
status
message
shortUrl
}
}
{
"data": {
"urlShortener": {
"status": 200,
"message": "Successfully shortened url",
"shortUrl": "https://blty.herokuapp.com/enyata"
}
}
}
This redirects the short url to it's corresponding long url