import { useEffect, useRef } from 'react';
export function Modal({ open, onClose, title, children }: any) {
const ref = useRef<HTMLDivElement | null>(null);
useEffect(() => {
import { useState, useEffect } from 'react'
export function useDebounce<T>(value: T, delay: number = 500): T {
const [debouncedValue, setDebouncedValue] = useState<T>(value)
useEffect(() => {
import { createConsumer, Cable } from '@rails/actioncable'
let cable: Cable | null = null
export function getCable(): Cable {
if (!cable) {
import nodemailer from 'nodemailer';
const transporter = nodemailer.createTransport({
host: process.env.SMTP_HOST,
port: Number(process.env.SMTP_PORT ?? 587),
auth: { user: process.env.SMTP_USER, pass: process.env.SMTP_PASS }
import { useState, useMemo, useCallback } from 'react'
import { Post } from '@/types'
import { PostCard } from './PostCard'
interface FilteredPostsProps {
posts: Post[]
import { Injectable } from '@nestjs/common';
export interface RateLimitResult {
allowed: boolean;
remaining: number;
limit: number;
import { useEffect, useState, useRef } from 'react'
interface UseInViewOptions {
threshold?: number | number[]
rootMargin?: string
triggerOnce?: boolean
import type { ErrorRequestHandler } from 'express';
export const errorMiddleware: ErrorRequestHandler = (err, req, res, _next) => {
const requestId = (req as any).requestId;
// eslint-disable-next-line no-console
console.error('api.error', { requestId, err: String(err?.message ?? err) });
type State = 'closed' | 'open' | 'half_open';
export function circuitBreaker<T>(fn: () => Promise<T>, opts: { failThreshold: number; coolDownMs: number }) {
let state: State = 'closed';
let failures = 0;
let openedAt = 0;
import type { Request, Response } from 'express';
import { pool } from '../db/pool';
export function liveness(_req: Request, res: Response) {
res.status(200).json({ ok: true });
}
import { useReducer } from 'react'
interface FormState {
values: Record<string, any>
errors: Record<string, string>
touched: Record<string, boolean>
// 1. Basic types
let username: string = 'Alex';
let age: number = 30;
let isActive: boolean = true;
let items: string[] = ['item1', 'item2'];
let numbers: Array<number> = [1, 2, 3];