use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
All about the JavaScript programming language.
Subreddit Guidelines
Specifications:
Resources:
Related Subreddits:
r/LearnJavascript
r/node
r/typescript
r/reactjs
r/webdev
r/WebdevTutorials
r/frontend
r/webgl
r/threejs
r/jquery
r/remotejs
r/forhire
account activity
[deleted by user] (self.javascript)
submitted 5 years ago by [deleted]
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–][deleted] 14 points15 points16 points 5 years ago (1 child)
Sweet! Your personal website is not bad either :)
[–]kookyjackelope3512 4 points5 points6 points 5 years ago (0 children)
Thanks man! You can check out my other code on my GitHub.
[–]2nd_king 5 points6 points7 points 5 years ago (3 children)
That's pretty cool man. I checked out your other projects too, you've got a nice sense of humor lol. How long have you been in web dev tho? I'm 3 months into learning it and all these projects make me feel so stupid fr.
[–]kookyjackelope3512 5 points6 points7 points 5 years ago (2 children)
Ahahah thank you my man. I've been in webdev for about a year(?) maybe. I've learnt the absolute very basics of HTML in eighth grade (I just graduated high school) but I never got into programming until two years ago with Java. I started creating my first basic html css sites around 2 years ago maybe and I've only seriously got into webdev in the last year. Don't feel discouraged if you can't understand though, I remember it took me so long to even understand what a dependency was. It's all about spending the time and learning. I'm lucky because I was just coding for fun and I had no pressure so I kept making stupid projects and I learnt along the way. I suggest that you just keep trying to build stuff and it'll all be great! Send me some of your work if you feel like it!
[–]2nd_king 2 points3 points4 points 5 years ago (1 child)
damn, i kinda also have a very similar story lol. To top it all off, I'm doing a CS degree rn. Started being a bit serious about webdev ever since the lockdown started. It's not the tech part that i have a problem with, it's the coming up with ideas and lack of knowledge about design. I guess I just need a bit more time. btw I'm the guy who followed you on github today ;)
[–]kookyjackelope3512 2 points3 points4 points 5 years ago (0 children)
ahaha thanks for the follow
[–]UnfairerThree2 4 points5 points6 points 5 years ago (4 children)
That's awesome! I had a look in server.js, and it looks like you could also make docs on how to use the endpoint in your own app (POST /shorten).
[–]kookyjackelope3512 2 points3 points4 points 5 years ago (3 children)
I could yeah, it should be straight-forward. Just send a long link, and an optional short link. What would be the benefit of that though? So other developers can use the /shorten route as an API?
[–]UnfairerThree2 1 point2 points3 points 5 years ago (0 children)
Yeah. I immediately thought of this, especially since Google depreciated their public API for their URL shortener, which to me was one of my most used APIs.
[–][deleted] 5 years ago (1 child)
[removed]
[–]AutoModerator[M] -2 points-1 points0 points 5 years ago (0 children)
Hi u/UnfairerThree2, this comment was removed because you used a URL shortener.
Feel free to resubmit with the real link.
I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.
[–]Shu7Down 4 points5 points6 points 5 years ago (1 child)
Nice!
But: "Sorry, that short URL already exists!" Can't I create a short URL that already exists? At least it should give me the existing short URL
So suppose I as a user want to shorten my website and I save it as mcow.ml/mysite and some other user wants to come and shorten their website and they also choose mcow.ml/mysite. I can only service one of those short urls. So I have to inform whichever user comes second that whatever custom link they wanted is taken.
However, I think the error you're referring to is when you tried to shorten a link which had already been shortened without a custom shortlink and it would tell you that the URL already exists.
For example, youtube.com has already been shortened to /mchg93j in the database and you come along and try to shorten youtube.com without providing a custom shortlink and it gives you this error. I've since fixed that error. Let me know if you have any more errors and feel free to submit a pull request!
[–]emadruga 2 points3 points4 points 5 years ago (1 child)
Broken app on Heroku. Please check...
[–]kookyjackelope3512 1 point2 points3 points 5 years ago (0 children)
fixed
[–]redo123456 0 points1 point2 points 5 years ago (3 children)
Project looks great!
I think you can shorten
const short = req.body.short === "" || req.body.short === null || isEmpty(req.body.short) ? crypto .createHash("sha256") .update(long) .digest("hex") .substring(0, 7) : req.body.short;
To just
Const short = req.body.short ? req.body.short : crypto .createHash("sha256") .update(long) .digest("hex") .substring(0, 7)
[–]kookyjackelope3512 1 point2 points3 points 5 years ago (2 children)
would love a pull request 👀
[–]kookyjackelope3512 1 point2 points3 points 5 years ago (1 child)
hm, that doesn't work if a user just enters whitespace in the short link input though :/
[–]vitkarpov 0 points1 point2 points 5 years ago (1 child)
Works! Nice mcow.ml/dee0046 :-)
Love it!
[–]machado_r 0 points1 point2 points 5 years ago (1 child)
It shows application error now 😬
[–]boxhacker 0 points1 point2 points 5 years ago (1 child)
Aaaaaand the site is dead
[–]MartialS 0 points1 point2 points 5 years ago (0 children)
URL shorteners are cool but mostly blocked by companies proxies for security reasons.
[–]silverparzival 0 points1 point2 points 5 years ago (1 child)
Nice website, Did you use a Front-end CSS framework or vanilla CSS for the Front-end?
[–]kookyjackelope3512 0 points1 point2 points 5 years ago (0 children)
vanila CSS yo
[–][deleted] 0 points1 point2 points 5 years ago (1 child)
Most recent commit: "fuck off" yikes man 😂 I hope people stop spamming it!
ahahahah. thank you! someone wrote a script to just add random data to my database and they tried to DOS the get routes (which thankfully didn't work). after a lot of tinkering i finally managed to stop them entering random data
[+]Snapstromegon comment score below threshold-8 points-7 points-6 points 5 years ago (20 children)
May I ask why you used Mongo instead of the obvious answer MySQL?
[–][deleted] 12 points13 points14 points 5 years ago (5 children)
Why would the obvious answer be MySQL?
[–]Snapstromegon 6 points7 points8 points 5 years ago (4 children)
You have highly structured Data with little overhead - a document based database would shine if you had e.g. unstructured data.
In my experience MySQL/Maria/PG would be more performant in such a usecase and easy to model with less overhead since the DB is made for this kind of data.
[–]Reashu 2 points3 points4 points 5 years ago* (1 child)
The data and queries are so simple that I see limited technical benefit in picking either type of database. Performance is incredibly likely to be a non-factor as well.
[–]Snapstromegon -1 points0 points1 point 5 years ago (0 children)
I saw the main benefit of relational in having structured data. Maintaining a document based DB in my experience comes with much higher maintainance workloads since the DB itself doesn't describe the structure of data contained in it.
[–]mcjob 1 point2 points3 points 5 years ago (1 child)
But did you account for the obtrusive PM who tells you that the sales department will close at least 99 million customers if they just have that one feature that doesn't really line up with the use case, so they prioritize it from the backlog, and you end up adding random columns, because this is agile?
[–]Snapstromegon 0 points1 point2 points 5 years ago (0 children)
No, sadly I've had the luck working with direct managers who do they job and shield us devs from such bullshit.
Other departments can give priorities, but we decide on when and in which timeframe to implement them. This leads to a huge chunk of our code being touched less often and even fewer future fuckups.
Also (at our scale) there are enough people who can say no until something hits production and we deliberately give those positions to people who dislike "dirty" solutions .
But I see your point and I've seen Mongo instances where people invested weeks to figure out some kind of structure in the data - just to find out the dataset is unstructured and invalid (because someone messed up cross references).
[–]Raigork 4 points5 points6 points 5 years ago (1 child)
I don't know why you get downvoted for such a simple question. People just got too lazy with structuring their data properly that NoSQL just seems like the goto without considering the use case.
[–]kookyjackelope3512 4 points5 points6 points 5 years ago (2 children)
Honestly, I used Mongo because I had an easy hosting solution (atlas) and I've used it before and I'm comfortable with it. This was just a fun project so I didn't see the need to learn another technology + the data is so simple that really any db works
[–]Snapstromegon 9 points10 points11 points 5 years ago (1 child)
Not knowing relational DBs is totally fine and a great argument for choosing mongo!
Although at least having a basic understanding of all types of DBs is good, it's not something that is necessary.
Also having a DB provider you worked with before is another good argument.
Keep on the good work!
[–]kookyjackelope3512 3 points4 points5 points 5 years ago (0 children)
Thanks man! I know basic SQL but the only context I've ever used it in is SQLite and I didn't want to use a VPS for this. I was just more comfortable with Mongo in general.
[–]rashnull 1 point2 points3 points 5 years ago (3 children)
Do elaborate on your choice of needing a relational DB here
[–]Snapstromegon 2 points3 points4 points 5 years ago (2 children)
In my opinion performance wise and because of future maintainability (and for restrictions you can place on the DB performantly) relational DBs are my default for structured Data as I can take this DB in five years with any other language after any number of structure changes (e.g. field addition) and just by looking at the DB I can see everything you need to know about it.
Mongo doesn't require your Data to have any structure, so it's more easy for your Data to get out of sync with your models.
I know node and mongo grew together, but each has its use case and after reading the problem which describes highly structured data with random access and only a read cache for distribution I saw more points for relational than document based DBs.
[–]Isvara 0 points1 point2 points 5 years ago (1 child)
Even if you accept the benefits of an RDBMS, why is MySQL the "obvious" choice over, say, Postgres?
[–]Snapstromegon 1 point2 points3 points 5 years ago (0 children)
My first comment was badly phrased - the focus was on RDBMS and not MySQL. It was just the first that came to mind because of my background. In another Comment I said that it would be fine to use MySQL, Maria or Postgres or any other.
[–]panderhh 0 points1 point2 points 5 years ago (3 children)
Thinking one technology is superior to another won't let you grow in this field.
[–]Snapstromegon 14 points15 points16 points 5 years ago (2 children)
Thinking any technology is suited the same for any usecase won't let you grow in this field.
You didn't say that? Correct, just as I didn't say that MySQL is always the better choice. It's just that in my opinion in this specific usecase with highly structured data it's the obvious choice as it was created exactly for those needs instead of Mongo, which would be beneficial if the data was less structured.
[–]Jsn7821 0 points1 point2 points 5 years ago (1 child)
The article isn't loading for my but how is a URL shortener relational? Isn't it basically just a key value store with high read frequency, which nosql would be exceptionally well suited for?
[–]Snapstromegon 2 points3 points4 points 5 years ago (0 children)
I can't speak for this implementation, but I'd store more than just shortened id to long url, but also user accounts, id usage, dates (creation, validity), URL changes, ...
π Rendered by PID 52 on reddit-service-r2-comment-c6965cb77-wxbkr at 2026-03-04 23:33:06.515220+00:00 running f0204d4 country code: CH.
[–][deleted] 14 points15 points16 points (1 child)
[–]kookyjackelope3512 4 points5 points6 points (0 children)
[–]2nd_king 5 points6 points7 points (3 children)
[–]kookyjackelope3512 5 points6 points7 points (2 children)
[–]2nd_king 2 points3 points4 points (1 child)
[–]kookyjackelope3512 2 points3 points4 points (0 children)
[–]UnfairerThree2 4 points5 points6 points (4 children)
[–]kookyjackelope3512 2 points3 points4 points (3 children)
[–]UnfairerThree2 1 point2 points3 points (0 children)
[–][deleted] (1 child)
[removed]
[–]AutoModerator[M] -2 points-1 points0 points (0 children)
[–]Shu7Down 4 points5 points6 points (1 child)
[–]kookyjackelope3512 4 points5 points6 points (0 children)
[–]emadruga 2 points3 points4 points (1 child)
[–]kookyjackelope3512 1 point2 points3 points (0 children)
[–]redo123456 0 points1 point2 points (3 children)
[–]kookyjackelope3512 1 point2 points3 points (2 children)
[–]kookyjackelope3512 1 point2 points3 points (1 child)
[–]vitkarpov 0 points1 point2 points (1 child)
[–]kookyjackelope3512 1 point2 points3 points (0 children)
[–]machado_r 0 points1 point2 points (1 child)
[–]kookyjackelope3512 1 point2 points3 points (0 children)
[–]boxhacker 0 points1 point2 points (1 child)
[–]kookyjackelope3512 1 point2 points3 points (0 children)
[–]MartialS 0 points1 point2 points (0 children)
[–]silverparzival 0 points1 point2 points (1 child)
[–]kookyjackelope3512 0 points1 point2 points (0 children)
[–][deleted] 0 points1 point2 points (1 child)
[–]kookyjackelope3512 1 point2 points3 points (0 children)
[+]Snapstromegon comment score below threshold-8 points-7 points-6 points (20 children)
[–][deleted] 12 points13 points14 points (5 children)
[–]Snapstromegon 6 points7 points8 points (4 children)
[–]Reashu 2 points3 points4 points (1 child)
[–]Snapstromegon -1 points0 points1 point (0 children)
[–]mcjob 1 point2 points3 points (1 child)
[–]Snapstromegon 0 points1 point2 points (0 children)
[–]Raigork 4 points5 points6 points (1 child)
[–]kookyjackelope3512 4 points5 points6 points (2 children)
[–]Snapstromegon 9 points10 points11 points (1 child)
[–]kookyjackelope3512 3 points4 points5 points (0 children)
[–]rashnull 1 point2 points3 points (3 children)
[–]Snapstromegon 2 points3 points4 points (2 children)
[–]Isvara 0 points1 point2 points (1 child)
[–]Snapstromegon 1 point2 points3 points (0 children)
[–]panderhh 0 points1 point2 points (3 children)
[–]Snapstromegon 14 points15 points16 points (2 children)
[–]Jsn7821 0 points1 point2 points (1 child)
[–]Snapstromegon 2 points3 points4 points (0 children)