Skip to content

Instantly share code, notes, and snippets.

View MendyLanda's full-sized avatar

Mendy Landa MendyLanda

  • Vienna, Austria
View GitHub Profile
@MendyLanda
MendyLanda / drizzle-ulid.md
Created November 5, 2023 13:29
Implementing Efficient Binary ULID Storage in MySQL with Drizzle ORM

For anyone considering the use of ULIDs in MySQL with drizzle, here's a ready-to-use ULID type for your convenience.

import { Ulid as ULID } from "id128";

export const ulid = customType<{
  data: string;
  notNull: true;
  default: false;
@MendyLanda
MendyLanda / ts-permissions-config.md
Created August 3, 2023 10:29
A Shared Permissions Config for Backend and Frontend with TypeScript

A Shared Permissions Config for Backend and Frontend with TypeScript

In this post, I'm going to share an approach I used to design a role-based access control system with TypeScript. The unique aspect of this system is the shared permissions config, which can be utilized both on the backend (for access control) and on the frontend (for UI control). The main idea is to design a robust and type-safe system that ensures users have the correct permissions for their tasks.

Setting up Roles

Firstly, I define several roles representing different types of users within the system:

export type Role = 'owner' | 'admin' | 'manager' | 'user';