A functional URL shortener made with TypeScript
Using yarn
to install all dependencies
yarn
Compile TypeScript to Javascript
yarn build:watch
To run the server
yarn dev
Create a .env
file and set these environment variables
MONGO_CONNECTION=Your mongodb uri
API_URL=Your server address(ex: http://localhost:5500)
PORT=Some valid port in your system (default is 5500)
-
[POST]
API_URL/shorter
Curl
curl -XPOST -H "Content-type: application/json" -d '{ "originUrl": "http://www.example.com"}' "http://localhost:5500/shorter"
-
[GET]
/:hash
You must give a valid hash as a param, you can get it creating a shortened url
- Create a URL shortener
- Redirect the original site
I was rusty programming, so i decided to create a simple project to practice some typescript and node tools.
You can open an issue or send me a email