Hey, did you feel something? I hope not.
I've deployed a new version of the One Post Wonder source code. And it should be... exactly the same, for you. If not, please let me know.
For avoidance of confusion: if something seems busted, it's not you, it's me. Let me know. Thanks! I did lots of testing. But... software is hard.
Just in case, my email is email@example.com. If stuff broke, tell me things ASAP. Thanks!
"So... if everything is the same... what's different?"
I rewrote the code using a modern idiom that other programmers will be able to follow. Which makes it more practical for others to help me move OPW forward. It's a hell of a lot easier for me to maintain the code as well.
You see, back in the Bad Old Days, Node.js programming was like this:
"Hey Jane, fetch me some blog posts, then call me." [Hand-sign of phone]
"Hey Jack, when Jane calls me, fetch some comments, then call me." [Hand-sign of phone]
"Hey Joe, when Jack calls me after Jane calls me, fetch some images, then call me." [Hand-sign of phone]
Except dozens of requests are coming in at once so it's like a telethon in there with only one person manning the phones and everybody wants a fucking tote bag and theoretically that's OK because you don't actually speak continuously to one person right, so...
AAAAAAAA yeah complete madness.
MOTHER MAY I fetch some blog posts.
MOTHER MAY I fetch some comments.
MOTHER MAY I fetch some images.
And the performance benefits are real enough that these days, Ruby, Python, PHP and even Rust optionally offer the same thing for those who need the speed.
So, we've got that going for us.
[Waves tattered flag]
Wait. Why do we do this?
A person might ask why programmers put up with any of this. Java and Python and Ruby and frickin' PHP all let you just write:
Do a thing
Do another thing
Do a third thing
Well... because it's fast. Most languages for the web give you a separate thread, aka basically a completely separate telethon volunteer, to think about each request, aka person calling to get a tote bag. Which is enormously convenient. But, also slower because you're not maximizing the throughput of your telethon volunteers.
Um... great! What's next?
"So what's next?" New features? Probably new features. I promised alt attributes a LONG time ago.
Probably also breaking up that massive "routes.js" file into separate collections of API routes by topic, so I can find stuff.
Probably also TypeScript, just so I can put "8 billion years TypeScript experience" on my resume.
Thank you sir, may I please have another?
So it's a good thing.
One may well ask: does that mean TypeScript can check the original "MOTHER MAY I" incantations (aka "await" keywords) to make sure none are missing? That would be seriously useful.
Oh gosh no, it can't do THAT. Who would want to catch by far the most common source of bugs in a Node.js program? No, it only stops you if you pass a string instead of a number (*), which I practically never do.
But I hear you can do it if you combine TypeScript and eslint and a roll of duct tape. So maybe I'll give that a try.
(*) Yes, yes, and a thousand more complicated but ultimately similar things.