December 18, 2019

Day #20 – Rate limiting & email templates

Topher @toadally

I added in rate limiting to FormCaster today. There isn’t ton to say about that. Essentially I’m just limiting specific activities to a certain number of actions over a specific amount of time. Those limits depend on the activity being undertaken, as some are more acceptable than others – for example static file access is less restricted than form submission.

Next I added in Nunjucks from Mozilla. It’s a clean and light templating engine much like Liquid or Jinja2. Here I’m using it to populate static HTML files containing the platform’s emails with use variables, and then output that parsed HTML in a string to be passed to Mailgun for email sending.

Hey look at that, some code. Really simple, right? I quite like using Nunjucks for email template handling. This is a little more simple implementation than I’ve used before, and this is hardly the first time I’ve used Nunjucks for this. I’m pleased every time I do use them.

Loading comments...