A charming and minimalist URL-shortening service. ☕ 🍩
This repository contains the source code for Mocha. Mocha is a url-shortening service. The frontend is written in Typescript using React and Deno. The backend is an API service written in Rust using Actix Web and SQLx.
THIS PROJECT IS STILL SOMEWHAT WORK IN PROGRESS.
- Make a logo.
- Complete the unit tests for both backend and frontend.
- Fig. 1: Save a link.
- Fig. 2: Retrieve the saved link by the links's ID.
Mocha allows you to save links in a database and then retrieve information about the saved link through a link ending in the link's ID. As illustrated in Fig 1, there are two fields: i) the "Name" field and ii) the "Link URL" field. The "Name" field allows you to name the link you want to save in a unique and distinct way. The "Link URL" field is the field expecting the link's URL. To save the link together with the link's name, you click the "Submit" button. If saving the link is successful, a text field will appear featuring the ID of the link. If you append this ID to the main URL of the address that Mocha is online at, you will get a page featuring the link and more information on it, as illustrated on Fig. 2. If you click the "Visit Link" button, you will be taken to the page the URL of the link points to.
Mocha offers the following API routes:
/submit
: This route accepts aPOST
request with a JSON payload of the following structure (The response will be in JSON format and feature all information on the saved link.):
{
"name": "Alyx's Website",
"time": "2024/11/28/11:11:45",
"link": "https://alyxshang.boo/"
}
/retrieve/id
: This route accepts aGET
request where the final part of the path,id
, is the ID of the link to be retrieved. The response will be in JSON format and feature all information on the saved link.
To run this project locally on your own device, please make sure you have Docker and Git installed. Follow the steps outlined below to run Mocha:
- 1.) Clone this repository by running the following command from a terminal session:
git clone https://github.com/alyxshang/mocha
. - 2.) Change directory into Mocha's root directory.
- 3.) Set the environment variable
POSTGRES_PASSWORD
to a not-empty string. - 4.) Run the command
docker-compose build
. - 5.) Run the command
docker-compose up
. - 6.) Mocha's frontend should be now running on
http://0.0.0.0:4000
. - 7.) Mocha's backend should be now running on
http://0.0.0.0:3000
.
- Mocha ☕ 🍩 by Alyx Shang 🖤.
- Licensed under the FSL v1.