typescript

typescript
export async function retry<T>(fn: () => Promise<T>, opts: { attempts: number; baseMs: number; maxMs: number }) {
  let lastError: unknown;
  for (let i = 0; i < opts.attempts; i++) {
    try {
      return await fn();
    } catch (e) {

Exponential backoff with jitter for retries

typescript reliability
by Mateo Rodriguez 1 tab
typescript
export function limit(concurrency: number) {
  let active = 0;
  const queue: Array<() => void> = [];

  const next = () => {
    active -= 1;

Simple concurrency limiter for batch operations

node performance
by Mateo Rodriguez 1 tab
typescript
import axios, { AxiosError } from 'axios'
import { v4 as uuidv4 } from 'uuid'

const api = axios.create({
  baseURL: import.meta.env.VITE_API_URL || 'http://localhost:3000/api/v1',
  timeout: 15000,

Axios API client with interceptors

react axios api
by Maya Patel 1 tab
typescript
import { create } from 'zustand'
import { persist } from 'zustand/middleware'

interface FilterState {
  search: string
  category: string | null

Zustand for lightweight state management

react zustand state-management
by Maya Patel 2 tabs
typescript
import crypto from 'node:crypto';
import jwt from 'jsonwebtoken';

export function signAccessToken(payload: object) {
  return jwt.sign(payload, process.env.JWT_SECRET!, { expiresIn: '15m' });
}

JWT access + refresh token rotation (conceptual)

auth security node
by Mateo Rodriguez 1 tab
typescript
import React from 'react';

type Props = { children: React.ReactNode; fallback?: React.ReactNode };

export class ErrorBoundary extends React.Component<Props, { hasError: boolean }> {
  state = { hasError: false };

React Error Boundary + error reporting hook

react frontend reliability
by Mateo Rodriguez 1 tab
typescript
import compression from 'compression';
import type { Express } from 'express';

export function applyCompression(app: Express) {
  app.use(
    compression({

Response compression (only when it helps)

node performance http
by Mateo Rodriguez 1 tab
typescript
import { Navigate, useLocation } from 'react-router-dom'
import { useAuth } from '@/contexts/AuthContext'

interface ProtectedRouteProps {
  children: React.ReactNode
}

React Router with protected routes

react react-router routing
by Maya Patel 2 tabs
typescript
import type { NextFunction, Request, Response } from 'express';
import crypto from 'node:crypto';
import pino from 'pino';

const baseLogger = pino({
  level: process.env.LOG_LEVEL ?? 'info',

Request ID + structured logging (Express + pino)

node express logging
by Mateo Rodriguez 1 tab
typescript
export function toFieldErrors(err: any): Record<string, string> {
  if (err?.error !== 'VALIDATION_ERROR' || !Array.isArray(err.issues)) return {};
  return Object.fromEntries(err.issues.map((i: any) => [String(i.path ?? 'unknown'), String(i.message ?? 'Invalid')])) as Record<
    string,
    string
  >;

Frontend: normalize and display server validation errors

frontend ux typescript
by Mateo Rodriguez 1 tab
typescript
import cron from 'node-cron';
import { withAdvisoryLock } from '../db/advisory-lock';

export function startCron() {
  cron.schedule('0 * * * *', async () => {
    await withAdvisoryLock('cron:hourly-rollup', async () => {

Cron scheduling with node-cron (with guard)

node jobs reliability
by Mateo Rodriguez 1 tab
sql
CREATE TABLE IF NOT EXISTS outbox_events (
  id BIGSERIAL PRIMARY KEY,
  event_name TEXT NOT NULL,
  dedupe_key TEXT NOT NULL UNIQUE,
  payload JSONB NOT NULL,
  status TEXT NOT NULL DEFAULT 'pending',

Transactional outbox in Node (DB write + event)

node postgres reliability
by Mateo Rodriguez 2 tabs