typescript

typescript
import https from 'node:https';

export const httpsAgent = new https.Agent({
  keepAlive: true,
  maxSockets: 50,
  timeout: 30_000

HTTP keep-alive agent for outbound calls

node http performance
by Mateo Rodriguez 1 tab
typescript
import request from 'supertest';
import { app } from '../server/app';

describe('POST /projects', () => {
  it('returns 400 for invalid payload', async () => {
    const res = await request(app).post('/projects').send({ name: '' });

Testing Express routes with Supertest + Jest

testing node express
by Mateo Rodriguez 1 tab
typescript
import { useEffect } from 'react'

interface KeyboardHandlers {
  [key: string]: () => void
}

Keyboard navigation and focus management

react accessibility keyboard
by Maya Patel 2 tabs
typescript
import { z } from 'zod';

const Env = z.object({
  NODE_ENV: z.enum(['development', 'test', 'production']).default('development'),
  DATABASE_URL: z.string().min(1),
  REDIS_URL: z.string().min(1).optional(),

Typed env parsing with zod

node typescript config
by Mateo Rodriguez 1 tab
typescript
import ReactMarkdown from 'react-markdown'
import remarkGfm from 'remark-gfm'
import rehypeSanitize from 'rehype-sanitize'
import { Prism as SyntaxHighlighter } from 'react-syntax-highlighter'
import { tomorrow } from 'react-syntax-highlighter/dist/esm/styles/prism'

Markdown rendering with react-markdown

react markdown content
by Maya Patel 1 tab
typescript
import { defineConfig } from 'vite'
import react from '@vitejs/plugin-react'
import path from 'path'

export default defineConfig({
  plugins: [react()],

React app structure with Vite and TypeScript

react vite typescript
by Maya Patel 2 tabs
typescript
export type PageInfo = {
  endCursor: string | null;
  hasNextPage: boolean;
};

export type Page<T> = {

API pagination response contract (page info)

api typescript
by Mateo Rodriguez 1 tab
typescript
import React, { createContext, useContext, useState, ReactNode } from 'react'

type ToastType = 'success' | 'error' | 'info' | 'warning'

interface Toast {
  id: string

Toast notifications system

react notifications context
by Maya Patel 1 tab
typescript
import crypto from 'node:crypto';

export function base64url(buf: Buffer) {
  return buf.toString('base64').replace(/+/g, '-').replace(///g, '_').replace(/=+$/g, '');
}

OAuth PKCE flow (high level helper)

auth security oauth
by Mateo Rodriguez 1 tab
typescript
import { useEffect, useRef } from 'react';

export function useInfiniteScroll(onLoadMore: () => void, enabled: boolean) {
  const ref = useRef<HTMLDivElement | null>(null);

  useEffect(() => {

IntersectionObserver infinite scroll hook

react frontend
by Mateo Rodriguez 1 tab
typescript
export const openapi = {
  openapi: '3.0.3',
  info: { title: 'Codesnips API', version: '1.0.0' },
  paths: {
    '/projects': {
      post: {

OpenAPI generation for REST endpoints

api docs typescript
by Mateo Rodriguez 1 tab
typescript
export const env = {
  apiBaseUrl: import.meta.env.VITE_API_BASE_URL as string
};

Vite env handling: explicit prefixes only

vite frontend config
by Mateo Rodriguez 1 tab