Share your repls and programming experiences

← Back to all posts
shrtr
caiocampos (4)

A new URL shortener

Some days ago I created my account here on Repl.it, my main idea was to check if the platform was good to recommend to a friend of mine who just started programming.
At first I searched for a good idea of something to do and I found this Repl (https://repl.it/talk/learn/Build-your-very-own-URL-shortener/9611), but had problems with the jsonstore.io that wasn't working very well.
So I had the idea of making a version that didn't depend on anything external, and this is the result.

I used TingoDB, so is easy to migrate do MongoDB (that's why I chose it).

Commentshotnewtop
Zavexeon (976)

https://shrtr.caiocampos.repl.co/q8kmddslwiAi

So I tried shortening the link to your shortener, but it only made the link longer. 1/10.

All jokes aside, pretty nifty program!

caiocampos (4)

@Zavexeon, I chose to generate a longer string than the original to have a better chance of not repeating, since I'm using random numbers to generate (and numbers are limited), you can use the alias to make a shorter link 😄

amasad (2065)

Awesome! So the database is hosted in memory?

caiocampos (4)

@amasad, the way I implemented Shrtr the data is stored in files, but it keeps a cache in memory. But it can also be used with in memory storage, just change the setting in api/repository/abs-repository.js file.

If I understood the documentation correctly you will need to change to something like this:
const {ObjectID, Db} = require('tingodb')({memStore: true});

caiocampos (4)

I found some people were tried to create links without "http://" or "https://", it's kind of embarrassing but I had not tested this kkkk.
I changed the code to try to address the issues related to it.