30 Days of Code — Day 8
Simple TTRPG Dice Roller
I realized I’ve been writing this as a weird combination of a tutorial and a journal, and I want to try to be a little more intentional with the way I do the remainder of this 30 day challenge. Moving forward I will just show what I’ve done between articles, explain why I did certain things, and only really do step-by-step explanations if it’s something really interesting or nuanced or confusing.
I’ve done quite a few things since I wrote yesterday’s article. The first thing being the roll history. When a user rolls the dice it is saved to local (browser) storage using the @Ionic/Storage package.
To achieve this, I created a new component called ResultHistory which reads the contents of the local storage and renders a list of the results in it sorted by the timestamp with the newest at the top. I had to make a slight change to the API to make this possible as I wasn’t previously capturing a timestamp when the dice was rolled. Finally, I added a Clear button so the user can wipe the rolls from localstorage if they want to.
You may also notice I moved the current result above the Roll button as it made it less annoying to use on mobile, and it felt better visually. The final frontend/visual change I made was to the favicon. I replaced the default Vite favicon with a D20 icon. It’s not sized quite right, so I will want to replace it again, but for now it’s good and it gets rid of the default.
Monetization
Yesterday I brought up future monetization plans. While I still think it’s a bit too early to really worry about it, I wanted to play around with RapidAPI and see what was involved in listing an API there. I was pleasantly surprised by how easy it was to get up and running, and it’s given me some ideas for future projects.
Once I got it hooked up I was able to add and customize the tiers. I have a pretty limited free tier, and then the paid tiers are probably overkill for anything else. In fact, I might have to limit them further to prevent malicious misuse.
That said, what I like about this is that RapidAPI takes care of the rate limits for me! This should prevent anyone from going crazy with the API and racking up a huge bill through Vercel. This is exactly the kind of thing I wanted to get out of this 30 day challenge. Is this a groundbreaking project? No. But will this help me a ton with future project? Absolutely! I can’t wait to see what else I can pick up in the remaining days.
Over the coming days I want to explore other avenues to monetize the project, but for now I’m really happy with where I’m at.