DEV Community

Cover image for In 48 hours, I’ve created License Key APIs using Supabase.
deepu
deepu

Posted on

In 48 hours, I’ve created License Key APIs using Supabase.

Background — TL;DR

I have business use cases around license keys for my macOS app so I went with Paddle who has both license keys + payments, for no reason, they’ve suspended my account. Literally, the next step I had taken was to build my own(not a fun thing to do because it is like reinventing the wheel) using Supabase.

This is the app where I am using the License key use-cases: https://zenmode.carrd.co/

Day 1: I scoped down my business use cases as follows:

  1. License generation
  2. License activation
  3. License de-activation
  4. License verification
  5. License re-activation
  6. License revocation

License generation:

  • Basically generate unique license keys, so I simply went with UUID and in Supabase you can find the property.

License activation:

  • Since this is a macOS app, validate the license key with user details + some magic to ensure the license is activated for the first time user.

License de-activation:

  • If a user wants to deactivate the license temporarily or switching to a new device then user has to deactivate the license key first before activating to a new device.

License verification:

  • Basically X number of times per week the backend validates with frontend whether the license key is valid or not.

License re-activation:

  • When a user needs to use the app on their new device, they have to unregister first on their old device and re-activate on new device.

License revocation:

  • For any bad reason, revoke the license

Day 2: Build tables based on the use-cases and write procedural functions to handle backend logic

Tables

  • Table to maintain user information
  • Table to maintain user license information and activities

Procedural functions

  • Translated each business use-case as function or functions, behind the scenes Supabase converts each function as an API.

--

Pros:

  • I’ve pretty much created all the APIs using procedural functions which is just like writing sql queries.
  • All functions are automagically converted to APIs

Cons:

  • There is more error prone using procedural functions than writing down in server less functions(hoping supabase launches as soon as they can)
  • Because supabase functions are still wip, I can’t integrate with email services to send license keys so I had to manually send license keys to the user email.

You can checkout my app here https://zenmode.carrd.co/

Top comments (0)