Copied to Clipboard
- Forces refetch of updated list.
V. Supabase
1. Core Features
- Authentication & Authorization out of the box.
- Realtime (via Postgres subscriptions).
- Cloud integrations (email, phone, storage).
- Built-in SQL editor & API SDK.
2. Row-Level Security (RLS)
- Granular rules: who can read/write which rows.
- Example: A user can only see their own orders.
- Protects DB directly, not just API layer.
VI. PostgreSQL Essentials
1. Indexes
- Speed up searches like a dictionary reference.
-
Primary key index → unique IDs.
-
Composite index → combine fields (
username + email).
-
GIN index → full-text search (e.g., search "keyword" inside paragraph).
VII. Next.js 15 Advanced
1. Server Actions
- Skip API routes → hit DB directly.
- No HTTP overhead = faster & safer.
- Called via
useTransition from client.
2. Built-in Caching
- Next.js caches server action results by default.
- Avoids duplicate DB queries.
3. State Management
- Remote: Server Actions + cache.
- Local (client): Context API.
- Local (server): Params, cookies.
VIII. React 19 Features
1. use() Hook
- Replace
useEffect + useState for data fetching.
- Works in server + client components.
- Example:
const data = use(fetchUser())
- Suspense pauses UI until ready → smoother UX.
2. Suspense
- Show fallback (
loading...) until data loads.
- Prevents partial/flickering UI.
3. React Compiler
- New optimization → auto-memoizes expensive renders.
- Reduces need for
useMemo & useCallback.
IX. NestJS Concepts
1. Guards
- Run before controller.
- Used for auth, permissions, points validation.
2. Middleware
- Run before controller OR before response leaves server.
- Generic → can log, validate, modify requests/responses.
3. Interceptors
- Used for transforming response/request.
- Example: file upload, logging, wrapping responses.
X. Design Patterns (Refactoring Guru style)
1. Singleton
- Only one instance.
- Example: DB connection.
2. Observer
- One-to-many dependency.
- Example: RxJS streams in NestJS.
3. Strategy
- Swap algorithms easily.
- Example: Payment methods (Stripe, PayPal).
4. Decorator
- Add behavior dynamically.
- Example: NestJS
@Controller, React HOCs.
5. Factory
- Create objects without knowing exact class.
- Example: NotificationFactory → Email/SMS/Push.
6. Adapter
- Makes incompatible interfaces work.
- Example: Wrap legacy API to work with new interface.
7. Proxy
- Control access to object.
- Example: API rate limiter, caching layer.
8. Builder
- Build complex objects step by step.
- Example: Build
User with optional props.
XI. Practical Mixed Questions
How to optimize frontend with heavy data lists?
→ Virtualization + TanStack Query cache + Suspense.
How to secure Supabase DB?
→ RLS + role-based auth + JWT in headers.
When would you use ISR over SSR?
→ If data changes occasionally (products, blogs). SSR if data changes on every request (stock price).
Explain Strategy Pattern with code.
→ PaymentStrategy interface → StripePayment & PaypalPayment classes → dynamically injected.
Why prefer Server Actions over API routes in Next.js?
→ Faster, secure (no network), less boilerplate.