You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
118 lines
2.6 KiB
Markdown
118 lines
2.6 KiB
Markdown
|
|
# MrKayJayDee Shortener
|
|
|
|
### A simple url shortener frontend and api using mongodb
|
|
|
|
<br>
|
|
|
|
# Setup
|
|
|
|
Clone the repo
|
|
```shell
|
|
git clone https://github.com/Mr-KayJayDee/simple-url-shortener
|
|
```
|
|
|
|
CD Into the directory
|
|
```
|
|
cd simple-url-shortener
|
|
```
|
|
|
|
Install the modules
|
|
```
|
|
npm install
|
|
```
|
|
|
|
Change the configuration
|
|
|
|
- Rename the .env.example to .env
|
|
- Change MONGO_URI to your mongodb local or cluster url
|
|
- Change BASE to your base url (localhost:8080 for local testing)
|
|
|
|
Change some others things
|
|
|
|
- Go to the index.html file and change the line 50 column 35 to be https://yourdomain.com/api/short
|
|
|
|
Start the server
|
|
```
|
|
node index.js
|
|
```
|
|
|
|
# API Reference
|
|
|
|
### Shorten a link
|
|
|
|
```http
|
|
POST https://mrkayjaydee.xyz/api/short
|
|
```
|
|
|
|
| Body | Type | Description |
|
|
| :-------- | :------- | :------------------------- |
|
|
| `origUrl` | `string` | **Required**. The url you want to shorten |
|
|
|
|
Returns
|
|
|
|
| Key | Type | Description |
|
|
| :-------- | :------- | :------------------------- |
|
|
| `urlId` | `String` | The URL ID |
|
|
| `origUrl` | `String` | The original URL |
|
|
| `shortUrl` | `String` | The shortened URL |
|
|
| `clicks` | `Number` | The amount of time this link has been clicked |
|
|
| `date` | `Date` | The creation date of this link |
|
|
| `_id` | `String` | The databse id of this link |
|
|
| `__v` | `Number` | The version number |
|
|
|
|
|
|
```json
|
|
{
|
|
"urlId": String,
|
|
"origUrl": String,
|
|
"shortUrl": String,
|
|
"clicks": Number,
|
|
"date": Date,
|
|
"_id": String,
|
|
"__v": Number
|
|
}
|
|
```
|
|
|
|
## Example
|
|
|
|
```http
|
|
POST https://mrkayjaydee.xyz/api/short
|
|
```
|
|
|
|
Body:
|
|
|
|
```json
|
|
{
|
|
"origUrl": "http://google.com"
|
|
}
|
|
```
|
|
Returns:
|
|
|
|
```json
|
|
{
|
|
"urlId": "9bcF-giN0",
|
|
"origUrl": "http://google.com",
|
|
"shortUrl": "https://mrkayjaydee.xyz/9bcF-giN0",
|
|
"clicks": 0,
|
|
"date": "2022-01-26T15:37:26.977Z",
|
|
"_id": "61f16ab602262b5f179d3336",
|
|
"__v": 0
|
|
}
|
|
```
|
|
|
|
# Contact Me:
|
|
|
|
- Discord: Mr¤KayJayDee#8961
|
|
- Support Server: https://discord.gg/5ZSGFYtnqw
|
|
- Shop Server: https://discord.gg/X2CHqpFPjw
|
|
- Instagram: [@killian.dalcin](https://www.instagram.com/killian.dalcin)
|
|
- Snapchat: [@killian.dalcin](https://www.snapchat.com/add/killian.dalcin)
|
|
- Twitter: [@killiandalcin](https://twitter.com/killiandalcin)
|
|
- Github: https://github.com/Mr-KayJayDee/
|
|
- Portfolio: https://portfolio.mrkayjaydee.xyz
|
|
- Fiverr: https://www.fiverr.com/mrkayjaydee
|
|
- Shoppy: https://shoppy.gg/@MrKayJayDee
|
|
- Email: [killian.dalcin@gmail.com](mailto:killian.dalcin@gmail.com)
|
|
- Email pro: [mrkayjaydee@gmail.com](mailto:mrkayjaydee@gmail.com)
|
|
- Email business: [contact@mrkayjaydee.xyz](mailto:contact@mrkayjaydee.xyz) |