Assumptions seem to never hold Having a single e-mail per account may be fine for the first customers of your SaaS, but you will quickly learn that users want to invite their colleagues. The assumption of “one e-mail address <> one account” is no longer good enough. The next step is to build a teams abstraction in your code, where one team consists of multiple users. Should you have built this…
When writing asynchronous javascript your code will contain a bunch of await and async, Promises and maybe callbacks. Here’s an example where we fetch a page and count the amount of div elements: As you write more and more code that is asynchronous, you will end up writing await quite a bit. In languages like Python and Go you write asynchronous code as if it’s synchronous. What if we…
Notebook systems for literate programming are increasingly popular. I’m talking about tools that allow you to mix code, text and rich content like Jupyter, Observable, and Starboard. For Starboard I wanted to be able to make changes to Starboard itself and plugins while being confident everything still works end to end. Testing in Jupyter The most serious tool I could find for Jupyter is…
Originally posted on the Sunder blog. Sunder is a framework for Service Workers like those found in Cloudflare Workers. It allows you to create testable APIs and websites in a similar way as you would using Node.js’s Koa or Express framework. Sunder is designed to be minimal, testable, and easy to understand. It’s only a few hundred lines of code. A small example 1 2 3 4 5 6 7 8 9 10…
Proof of work (PoW) algorithms generally have no notion of progress, instead they are more like playing the lottery millions of times until you win. Losing a million times doesn’t influence your chances of winning the next one. That’s ok and probably even desirable for applications like a cryptocurrency mining, but undesirable for an application like hashcash in which the proof of work…
Over the past two months I’ve built FriendlyCaptcha, a privacy friendly alternative to Google reCAPTCHA. Normally if I were to start a new web application, I would write the server code in Golang, spin up a Postgres instance, and host a dockerized version of it on Google Cloud Run to get many of the serverless benefits. For a CAPTCHA product the requirements were a bit different: it is…
In my current project I am trying to go full origin-less: everything runs in a CloudFlare worker script, there is no centralized server. These serverless Javascript environments often don’t run on Node, so there are a lot of libraries you can’t use. This makes going fully serverless painful, so far I had to implement the client code for Mailgun, BigQuery and Stripe myself. Each of…
In most serverless environments, Cloudflare Workers included, you can not send e-mail through SMTP. Also, many client SDKs for providers such as Mailgun or Sendgrid assume you are on the Node platform and will not work in many serverless runtimes. Luckily most providers also provide a REST API to send e-mail. I ended up going with Mailgun, below is some example Typescript code that works in…
As a followup to my previous post, I found that in practice embedding a WebAssembly binary in code as a base64 string using a bundler (such as Webpack or Rollup) is still not ideal. So I created a small tool, wasmwrap that generates a plain Javascript or Typescript file for you instead. To install it: npm install wasmwrap --save-dev Then you can use it as such: wasmwrap --input my-file.wasm…
Actually shipping compiled WebAssembly code can be tricky. Especially when you want the wasm module to be easy to install and use through NPM it gets complicated, users will have to use wasm plugins for their bundler of choice (such as Webpack or Rollup), or they will need to host the wasm file separately and pass it into your library. If the developer of this project does not interact with WASM…
⚠️ This article is outdated by now, AssemblyScript has changed quite a bit - you will have to change some things. AssemblyScript is a programming language that is almost the same as Typescript and compiles to WebAssembly. WebAssembly allows near-native speed for programs that rely on heavy computation with smaller binaries. Any modern browser nowadays supports it as well as Deno and Node. It will…