This is a fast and simple URL shortener built as a capstone project from AltSchool Africa.
-
Scisor allows users to shorten URLs by pasting a long URL into the Scissor platform and a shorter URL gets automatically generated. The shortened URL must be designed to be as short as possible, making it easy to share on social media or through other channels.
-
Scissor allows users to also generate and QR codes for the shortened URLs. Users can download the QR code image and use it in their promotional materials or/and on their website. This feature will be implemented using a third-party QR code generator API, which can be integrated into the Scissor platform.
-
Scissor provides basic analytics that allow users to track their shortened URL's performance. Users can see how many clicks their shortened URL has received and where the clicks are coming from. We need to track when a URL is used.
-
Scissor allows users to see the history of links they have created so they can easily find and reuse links they have previously created.
-
The URL should be validated before creating a shortened version of it so as to prevent broken links.
-
A cache-layer must be implemented to prevent hitting the DB always.
-
Rate limiting must be implemented
-
Unit and integration tests should be conducted where possible
-
Spec and document the API with OpenAPI using https://stoplight.io/
- Install Node.js, MongoDB, redis
- Install project dependencies
- clone this repo
- update env with example.env
- run
npm run start:dev
git clone https://github.com/adeyinkaoresanya/scissor.git
npm install
npm run start:dev
field | data_type | constraints |
---|---|---|
name | string | required |
string | required | |
password | string | optional |
createdAt | date |
field | data_type | constraints |
---|---|---|
urlId | string | required |
origUrl | string | required |
shortUrl | string | required |
clicks | number | required, default: 0 |
date | date | |
QRString | string | required |
user | ref - User | required |
- Route: /register
- Method: POST
- Body
{
"name": "Jane",
"email": "[email protected]",
"password": "Janebakes236!"
}
Response
{"name":"Jane",
"email":"[email protected]"}
- Route: /login
- Method: POST
Body
{
"email": "[email protected]",
"password": "Janebakes236!"
}
Response
{
"email": "[email protected]",
"token": { token }
}
- Route: /create
- Method: POST
- response cookies {token}
Request [Body]
{
"https://www.dataquest.io/blog/web-scraping-python-using-beautiful-soup/"}
Response
{
"urlId": "jxPhc",
"user": new ObjectId("64a2ae1043ef0a3eb98bf6d2"),
"origUrl": "https://www.dataquest.io/blog/web-scraping-python-using-beautiful-soup/",
"shortUrl": "https://scissor-v4pd.onrender.com/by-user/jxPhc",
"clicks": 0,
"date": "03-Jul-2023",
"QRString": "data:image/png;base64,..."
}
- Route: /by-user
- Method: GET
- response cookies {token}
Response
{
"urlId": "jxPhc",
"user": new ObjectId("64a2ae1043ef0a3eb98bf6d2"),
"origUrl": "https://www.dataquest.io/blog/web-scraping-python-using-beautiful-soup/",
"shortUrl": "https://scissor-v4pd.onrender.com/by-user/jxPhc",
"clicks": 0,
"date": "03-Jul-2023",
"QRString": "data:image/png;base64,..."
}
- Route: /by-user/:id
- Method: GET
- response cookies {token}
Response
{"origUrl": "https://www.dataquest.io/blog/web-scraping-python-using-beautiful-soup/",
}
- Route: /ScanQRCode/:id
- Method: GET
- response cookies {token}
Response
{
"QRString": "data:image/png;base64,..."
}
- Adeyinka Oresanya