typescript

typescript
import helmet from 'helmet';
import type { Express } from 'express';

export function applyHelmet(app: Express) {
  app.use(
    helmet({

Security headers with helmet (baseline hardening)

security node express
by Mateo Rodriguez 1 tab
typescript
import { setupServer } from 'msw/node';
import { http, HttpResponse } from 'msw';

export const server = setupServer(
  http.get('/api/snips/:id', ({ params }) => {
    return HttpResponse.json({ id: params.id, title: 'Demo', liked: false, likesCount: 0 });

MSW for frontend API mocking in tests

testing frontend react
by Mateo Rodriguez 1 tab
typescript
import crypto from 'node:crypto';

export function timingSafeEqual(a: string, b: string) {
  const ab = Buffer.from(a);
  const bb = Buffer.from(b);
  if (ab.length !== bb.length) return false;

Webhook signature verification (timing-safe compare)

node security webhooks
by Mateo Rodriguez 1 tab
typescript
import React, { createContext, useContext, useState, useEffect, ReactNode } from 'react'
import { User } from '@/types'
import api from '@/services/api'

interface AuthContextType {
  user: User | null

Context API for global UI state

react context hooks
by Maya Patel 1 tab
typescript
import DataLoader from 'dataloader';
import { withClient } from '../../db/pool';

export function createUserLoader() {
  return new DataLoader<string, any>(async (ids) => {
    const rows = await withClient(async (client) => {

N+1 avoidance with DataLoader (GraphQL)

graphql node performance
by Mateo Rodriguez 1 tab
typescript
import { render, screen } from '@testing-library/react'
import userEvent from '@testing-library/user-event'
import { PostCard } from '../PostCard'
import { Post } from '@/types'

const mockPost: Post = {

React Testing Library for component tests

react testing testing-library
by Maya Patel 2 tabs
typescript
import { JSDOM } from 'jsdom';
import createDOMPurify from 'dompurify';

const window = new JSDOM('').window as unknown as Window;
const DOMPurify = createDOMPurify(window);

Sanitize user HTML safely (DOMPurify + JSDOM)

node security html
by Mateo Rodriguez 1 tab
typescript
import { test, expect } from '@playwright/test';

test('login and see dashboard', async ({ page }) => {
  await page.goto('/login');
  await page.getByTestId('email').fill('demo@example.com');
  await page.getByTestId('password').fill('password123');

Playwright smoke test for auth flow

testing playwright frontend
by Mateo Rodriguez 1 tab
typescript
import { createClient } from 'redis';

export const redis = createClient({ url: process.env.REDIS_URL });

export async function cacheAside<T>(key: string, ttlSeconds: number, loader: () => Promise<T>): Promise<T> {
  const cached = await redis.get(key);

Redis cache-aside for expensive reads

node redis performance
by Mateo Rodriguez 1 tab
typescript
import { z } from 'zod'

export const postSchema = z.object({
  title: z
    .string()
    .min(5, 'Title must be at least 5 characters')

React Hook Form with Zod validation

react forms react-hook-form
by Maya Patel 2 tabs
typescript
import { Queue, Worker } from 'bullmq';
import IORedis from 'ioredis';

const connection = new IORedis(process.env.REDIS_URL!);

export const emailQueue = new Queue('email', { connection });

BullMQ worker with retries + dead-letter

node redis background-jobs
by Mateo Rodriguez 1 tab
typescript
import { useMutation, useQueryClient } from '@tanstack/react-query'
import api from '@/services/api'
import { Post, PostId } from '@/types'

export function useLikePost() {
  const queryClient = useQueryClient()

Optimistic updates with React Query mutations

react react-query optimistic-updates
by Maya Patel 2 tabs