惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

aimingoo的专栏
aimingoo的专栏
V
V2EX
G
Google Developers Blog
F
Full Disclosure
Martin Fowler
Martin Fowler
宝玉的分享
宝玉的分享
H
Hacker News: Front Page
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
NISL@THU
NISL@THU
G
GRAHAM CLULEY
V
Vulnerabilities – Threatpost
Hacker News - Newest:
Hacker News - Newest: "LLM"
A
About on SuperTechFans
The Cloudflare Blog
C
Cisco Blogs
D
DataBreaches.Net
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
Vercel News
Vercel News
P
Privacy International News Feed
Microsoft Security Blog
Microsoft Security Blog
Help Net Security
Help Net Security
Recorded Future
Recorded Future
PCI Perspectives
PCI Perspectives
S
Schneier on Security
AI
AI
N
News | PayPal Newsroom
雷峰网
雷峰网
C
Cyber Attacks, Cyber Crime and Cyber Security
P
Proofpoint News Feed
The Last Watchdog
The Last Watchdog
L
LINUX DO - 最新话题
Hugging Face - Blog
Hugging Face - Blog
Apple Machine Learning Research
Apple Machine Learning Research
Schneier on Security
Schneier on Security
S
Securelist
云风的 BLOG
云风的 BLOG
Stack Overflow Blog
Stack Overflow Blog
博客园_首页
AWS News Blog
AWS News Blog
TaoSecurity Blog
TaoSecurity Blog
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
Recent Commits to openclaw:main
Recent Commits to openclaw:main
博客园 - 三生石上(FineUI控件)
C
CXSECURITY Database RSS Feed - CXSecurity.com
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
Cloudbric
Cloudbric
C
Cybersecurity and Infrastructure Security Agency CISA
Project Zero
Project Zero
C
Check Point Blog
S
Security Affairs

DEV Community

Authentication Security Deep Dive: From Brute Force to Salted Hashing (With Java Examples) Why AI Systems Don’t Fail — They Drift Spilling beans for how i learn for exam😁"Reinforcement Learning Cheat Sheet" I Replaced Chrome with Safari for AI Browser Automation. Here's What Broke (and What Finally Worked) How Python Borrows Other People's Work The $40 Architecture: Processing 1 Billion API Requests with 99.99% Uptime Vibe Coding: A Workflow Guide (From Zero to SaaS) Most webhook security guides protect the wrong side. The scary part is delivery. Headless CMS for TanStack Start: Build a Blog with Cosmic EU Age Verification App "Hacked in 2 Minutes" — What Actually Happened Comfy Cloud’s delete function does not actually remove files Running AI Models on GPU Cloud Servers: A Beginner Guide Event-driven media intelligence with AWS Step Functions and Bedrock I scored 500 AI prompts across 8 quality dimensions — here's what broke How to Call Google Gemini API from Next.js (Free Tier, No Backend Needed) The Portal Protocol: Reclaiming Human Connection in the Age of AI How to Fix Your Team's Scattered Knowledge Problem With a Self-Hosted Forum Intro to tc Cloud Functors: A Graph-First Mental Model for the Modern Cloud Designing Multi-Tenant Backends With Both Ownership and Team Access I Built a Neumorphic CSS Library with 77+ Components — Here's What I Learned PostgreSQL Performance Optimization: Why Connection Pooling Is Critical at Scale Cómo construí un SaaS multi-rubro para gestionar expensas en Argentina con FastAPI + Vue 3 🚀 I Built an Ethical Hacking Scanner Tool – Open Source Project I Replaced /usage and /context in Claude Code With a Single Statusline A Pythonic Way to Handle Emails (IMAP/SMTP) with Auto-Discovery and AI-Ready Design I Collected 8.9 Million Polymarket Price Points — Here's What I Found About How Markets Really Move EcoTrack AI — Carbon Footprint Tracker & Dashboard Everyone's Using AI. No One Agrees How. 5 self-hosted ebook managers worth trying in 2026 Building Your First AI Agent with LangChain: From Chatbot to Autonomous Assistant Common SOC 2 Failures (Real World) Stop Vibe-Checking Your AI App: A Practical Guide to Evals How to Use SonarQube and SonarScanner Locally to Level Up Your Code Quality Your Next To-Do App Is Dead — I Replaced Mine with an OpenClaw AI Sign a Nostr event in 60 lines of Python using coincurve — no nostr-sdk, no nbxplorer, no rust toolchain ITGC Audit Explained Like You’re in Big 4 Patch Tuesday abril 2026: Microsoft parcha 163 vulnerabilidades y un zero-day en SharePoint Stop scraping everything: a better way to track competitor price changes Listing on MCPize + the Official MCP Registry while routing payments OUTSIDE the marketplace — how I kept 100% of my x402 revenue Building an AI-Powered Risk Intelligence System Using Serverless Architecture Why We Ripped Function Overloading Out of Our AI Toolchain Testing AI-Generated Code: How to Actually Know If It Works SaaS Churn Is Killing Your Business. Here Is What to Do About It (Without a Support Team) The Speed of AI Is No Longer Linear - And Self-Improving Models Are Why How to Implement RBAC for MCP Tools: A Practical Guide for Engineering Teams From Standard Quote to Persuasive Proposal: AI Automation for Arborists I built a CLI that scaffolds complete multi-tenant SaaS apps Axios CVE-2025–62718: The Silent SSRF Bug That Could Be Hiding in Your Node.js App Right Now The dashboard that ended our friendship Data Pipelines Explained Simply (and How to Build Them with Python) The Hidden Cost of AI Systems Nobody Talks About. undefined vs undeclared, and how typeof behaves Switching from file-based jobs to NATS/Kafka in Rust without changing code io_uring Adventures: Rust Servers That Love Syscalls Why Agentic AI is Killing the Traditional Database The POUR principles of web accessibility for developers and designers Quantum Neural Network 3D — A Deep Dive into Interactive WebGL Visualization How To Install Caveman In Codex On macOS And Windows Automation Pipeline Reliability: Why Your Workflow Breaks When Nobody Is Watching I Built an 'Open World' AI Coding Agent — It Works From ANY Folder From Freelancing to Product: A Tech Service Company's SaaS Transformation China's AI Giants: Adding Tencent Hunyuan & ByteDance Doubao to AI University (74 Providers) On the Vibe Coders and Their Lies clerk: Auto-Summarize Your Claude Code Sessions AI Weekly — 2026/04/10–04/17 | The Model Lockdown Is Here, but the Toolchain Is the Real Battleground AI 週報 — 2026/04/10–2026/04/17 模型封鎖潮來了,但工具鏈才是真戰場 Maybe this is how Open-Source apps are born... 🚀 Fine-Tune LLMs with LoRA and QLoRA: 2026 Guide tRPC v11 + Next.js App Router: End-to-End Type Safety Without the Boilerplate ShadCN UI in 2026: Why I Stopped Installing Component Libraries and Started Owning My Components SaaS Billing in React Server Components: Stripe + Supabase Without a Single `useEffect` Join our DEV Weekend Challenge — $1,000 in Prizes Across TEN winners! Submissions Due April 20 at 6:59 AM UTC. Implementing FSRS Spaced Repetition in Flutter + Supabase — Adding Memory Science to an AI Learning App "I Texted My Localhost From the Train — Claude Code Fixed the Bug Before I Got Home" I Built a Sales Prep AI and It Went Deeper Than Expected Design to Code #2: One JSON, Eleven Outputs Solving the 100M-Row Problem: A Summary Table Pattern for High-Volume Push Notification Logs Flutter Web With Wasm: What Actually Changes For Developers I Built 50 Royalty-Free Soundtracks for My Side Project in a Weekend Using AI Music Generation The Vibe Coding Security Checklist: 7 Things to Check Before You Ship Stop Letting Googlebot Guess Fix Your React App's SEO Right Desconstruindo o Streaming do LinkedIn: Como Criar um Engine de Extração de Vídeo de Alta Performance com HLS e FFmpeg (EDA Part-1) EDA (Exploratory Data Analysis) Explained With Real Life — Why Looking at Your Data Is the Most Important Step in Machine Learning Brand Relationship Management at Scale: Our 4-Touch Outreach System for 200+ Brands Why String.fromEnvironment() Might Return an Empty String in Dart JGuardrails 1.0.0 — Hardening Java LLM Apps Against Jailbreaks, Toxicity, and Prompt Injection Plan and Schedule a Full Week of Threads Content From One Claude Conversation Coding Cat Oran Ep3, Five Tables Changed Everything Updated: BFF Pattern I'm done watching freelancers get buried by 200 proposals. So I'm building the alternative. This is my first post BFS Algorithm in Java Step by Step Tutorial with Examples Tracking LLM Pricing Monthly: An Open Dataset for 22 AI Models How We Measure Content ROI on a Comparison Site: Revenue Attribution Without Perfect Data Introducing Nova AI Ops: The AI-Native Operating System for SRE Teams I built a free desktop video downloader for Windows — Grabbit How Talkie OCR Helps Vision-Impaired & Dyslexic Users Read the World Around Them VRCFaceTracking安装和iPhone面捕配置教程,有bug Even CrowdStrike Can't See Your Agents The Automation Gold Rush: What n8n Workflows and Claude Are Opening Up for Developers Right Now
Migrating Ekehi from Vanilla JS to a TypeScript Stack
AJ · 2026-06-20 · via DEV Community

Ekehi platform has moved from hand-written HTML/CSS/JS pages to a typed, component-driven React 19 client and a module-based TypeScript Express/Node.js API.

0. Where we started and where we landed

Before. A static client built from per-page folders (landing/,
contributors/, login/, signup/, admin/), each shipping its own
index.html, a shared styles.css, and vanilla ES module scripts under
client/shared/. The server was an Express API written in plain JavaScript.

After.

Layer Before After
Client Static HTML + CSS + vanilla JS React 19 + Vite 8 + TanStack Router + TypeScript 6
Styling One global styles.css Tailwind CSS 4 with @theme design tokens
Data fetch scattered per page TanStack Query over a typed lib/api client
Server Express in JavaScript Express + TypeScript, module-per-domain
Repo Two loose folders pnpm workspace with shared git hooks
Quality gate None ESLint 9, Prettier 3, Husky, commitlint, Vitest

The migration ran in two phases on separate branches:

  • **Phase 1 — client rewrite.
  • **Phase 2 — server rewrite.

1. Why this framework?

Choice: React 19, rendered as a client-side SPA through Vite 8, routed by TanStack Router.

TanStack Router was chosen rather than React Router because it
gives fully type-safe routes, first-class search-param typing, built-in code-splitting, and file-based route generation that pairs cleanly with Vite.


2. The folder and component structure

The client uses a feature-sliced layout: code is grouped by domain, not by
technical type.

client/src/
├── components/
│   ├── layout/         navbar.tsx, footer.tsx
│   └── ui/             button, input, modal, select, dropdown, ... (design system)
├── config/             env.ts, env-schema.ts, endpoints.ts
├── features/           one folder per domain
│   ├── auth/           auth.query.ts, auth.service.ts, auth.types.ts, components/, pages/
│   ├── opportunities/  pages/
│   ├── resources/      pages/
│   ├── submissions/    pages/
│   ├── admin/          pages/
│   └── site/           pages/ (landing, contributors)
├── lib/
│   ├── api/            request.ts, errors.ts, refresh.ts, types.ts  (HTTP client)
│   ├── auth/           token-store.ts
│   ├── query-client.ts
│   └── utils.ts
├── routes/             TanStack file-based route tree
├── router.tsx
├── routeTree.gen.ts    generated, do not edit
└── styles.css          Tailwind import + @theme tokens

The principle: a route file in routes/ is thin glue that points at a page component in the matching features/<domain>/pages/ folder. Domain logic (queries, services, types) lives next to the feature that owns it, so a single Claude or dev session can work one feature without touching another.

Imports use the #/* alias (defined in both package.json#imports and tsconfig.json#paths) so there are no ../../../ chains:

import { env } from '#/config/env'
import { getAccessToken } from '#/lib/auth/token-store'

3. Decompose the UI into reusable components

The old per-page markup was factored into a small design-system layer under components/ui/: button, input, password-input, textarea, select, checkbox, label, form-field, dropdown, modal, search-bar, skeleton.

Technique and libraries:

  • Radix UI primitives (@radix-ui/react-dialog, react-dropdown-menu, react-slot) supply accessible, unstyled behaviour (focus traps, keyboard nav, ARIA). The team styles them rather than reimplementing accessibility.
  • class-variance-authority (CVA) defines component variants (size, intent) as typed config instead of ad-hoc conditional class strings.
  • clsx + tailwind-merge (wrapped in lib/utils.ts) merge class names and resolve Tailwind conflicts deterministically.
  • lucide-react provides the icon set as tree-shakeable components.

Layout components (navbar, footer) live separately under
components/layout/ because they are app chrome, not reusable primitives.


4. Migrate static HTML sections into JSX

Each former page folder became a route + page component pair. The old
landing/index.html is now features/site/pages/landing-page.tsx mounted at
routes/(layout)/index.tsx; contributors/, login/, signup/, the admin screens, and the resource/opportunity pages followed the same move.

Shared chrome that used to be copy-pasted into every index.html now lives once:

  • routes/__root.tsx is the application shell.
  • routes/(layout)/route.tsx wraps every public page in the shared navbar/footer layout, so markup is defined a single time and inherited.

The vanilla client folders (client/shared/, client/landing/,
client/contributors/, etc.) and the root index.html/styles.css were deleted in the same release (see CHANGELOG.md [2.0.0] → Removed).


5. Migrate CSS with the framework's recommended approach

Styling moved to Tailwind CSS 4, installed as a Vite plugin
(@tailwindcss/vite) rather than a PostCSS pipeline — the v4 recommended path.

The single global stylesheet was replaced by a token-driven theme declared
with the new @theme directive in client/src/styles.css:

@import 'tailwindcss';

@theme {
  --color-purple-700: #730099;
  --color-primary: var(--color-purple-700);
  --color-surface: #ffffff;
  --color-surface-subtle: var(--color-neutral-50);
  /* ... */
}

Two deliberate techniques:

  • Role-based token names. Raw scales (purple-700, neutral-50) are mapped to semantic roles (primary, surface, content, line) so components reference intent, not hex values. See refactor(client): rename color tokens to role-based names (surface/content/line).
  • Deterministic class ordering. prettier-plugin-tailwindcss sorts utility classes on every format pass, so class lists never drift between authors.

Fonts are self-hosted via @fontsource-variable/inter and
@fontsource-variable/lora, and fontaine generates metric-matched fallback @font-face rules to eliminate layout shift on font swap.


6. Replace vanilla JS logic with framework equivalents

The biggest behavioural shift. Imperative fetch + DOM updates became declarative server-state managed by TanStack Query on top of a typed HTTP client.

The HTTP client (lib/api/request.ts). A makeRequest factory builds typed callers and centralises everything that used to be repeated per page:

  • attaches the bearer token from lib/auth/token-store,
  • serialises GET params vs JSON/FormData bodies,
  • unwraps the server's { success, data, meta } envelope,
  • and — critically — on a 401 it transparently calls refreshSession() and retries the original request once (skipping /auth/* routes to avoid loops):
if (response.status === 401 && !isRetry && !route.startsWith(AUTH_PATH_PREFIX)) {
  const refreshed = await refreshSession()
  if (refreshed) return executeRequest(route, method, options, true)
}

Server state via TanStack Query. Features expose typed hooks instead of inline fetch calls. Auth (features/auth/auth.query.ts) is representative:

export function useLoginMutation() {
  const queryClient = useQueryClient()
  return useMutation<LoginResponse, Error, LoginRequest>({
    mutationFn: (data) => AuthService.login({ data }).then((r) => r.data),
    onSuccess: (response) => {
      setTokens({ access_token: response.access_token,
                  refresh_token: response.refresh_token })
      queryClient.invalidateQueries({ queryKey: authKeys.me() })
    },
  })
}

Query keys are namespaced (authKeys), caching/invalidation is handled by the library, and useLogoutMutation clears the cache on settle. The shared client config lives in lib/query-client.ts.

Forms use React 19's useActionState. Login and signup wire the form action straight to the mutation, getting pending/error state from the framework with no manual loading flags.

Validation is shared end to end with Zod 4 — the same library validates client env, form input, and server request bodies.


7. Set up client-side routing

Routing is file-based through TanStack Router with autoCodeSplitting enabled in vite.config.ts, so every route is its own lazy chunk. The route tree under client/src/routes/ uses TanStack's grouping conventions:

routes/
├── __root.tsx                         app shell
├── (auth)/login.tsx, signup.tsx       auth pages (no app chrome)
├── (layout)/
│   ├── route.tsx                      shared navbar/footer layout
│   ├── index.tsx                      landing
│   ├── opportunities/index.tsx, $id.tsx
│   ├── resources/.../$id.tsx          training + guides, list + detail
│   └── (protected)/
│       ├── route.tsx                  auth guard
│       ├── submit.tsx, submissions.tsx, my-submissions.tsx
└── admin/index.tsx, queue.tsx, review.tsx

Three conventions do the heavy lifting:

  • (group) folders organise routes without adding URL segments — (auth), (layout), (protected) are structural, not path segments.
  • Pathless layout routes (route.tsx) inject shared UI and guards. The (protected)/route.tsx boundary enforces auth before any submission/admin page renders.
  • $id.tsx dynamic segments handle detail pages with type-safe params.

The generated routeTree.gen.ts is produced by the router plugin (or pnpm generate-routes) and must not be hand-edited.


8. Push to GitHub with clear, meaningful commits

The repo enforces Conventional Commits repo-wide through git hooks installed at the workspace root:

  • Husky 9 activates the hooks (.husky/).
  • commit-msg runs commitlint (@commitlint/config-conventional) on every message — feat(client): ..., refactor(server): ..., chore: ....
  • pre-commit runs lint-staged, auto-fixing staged files with eslint --fix and prettier --write so nothing unformatted lands.

Branching model (from CONTRIBUTING.md): branches start from and target development; main advances only via release merge. The migration itself


Server migration — JavaScript Express to TypeScript modules

Phase 2 rewrote the API in TypeScript 6 without changing the
runtime contract the client consumes.

Architecture: one module per domain. Each domain owns four files with a single responsibility each:

server/src/modules/<domain>/
├── <domain>.routes.ts       route table
├── <domain>.controller.ts   HTTP in/out only
├── <domain>.service.ts      business logic + Supabase calls
└── <domain>.schema.ts       Zod request validation

Domains: auth, admin, opportunities, trainings, guides, templates, profile, meta, health. The composition root is app.tsroutes.ts → each module's routes. Cross-cutting concerns live in middleware/
(authenticate, require-role, rate-limit, validate-request, upload, error-handler) and shared helpers in lib/ (response, http-error, async-handler, supabase, validation, storage, logger).

Toolchain:

  • tsx runs the dev server with watch mode (tsx watch src/server.ts) — no precompile step in development.
  • tsc + tsc-alias produce the production build, rewriting the #/* path alias to real relative paths in the emitted dist/.
  • Typed database access. pnpm db:types generates src/types/database.ts from the live Supabase schema, so queries are checked against the real table shapes.
  • Zod validates every request body before it reaches a controller, mirroring the client's use of the same library.

Security and ops middleware carried over and are now typed: helmet, cors, morgan, express-rate-limit, and multer for uploads.


Library reference

Every library introduced by the migration and the job it does.

Client

Library Role
react, react-dom 19 UI runtime; useActionState for form submission
vite 8 + @vitejs/plugin-react Build tool and dev server, React fast refresh
@tanstack/react-router (+ router-plugin) Type-safe, file-based, code-split routing
@tanstack/react-query Server-state cache, mutations, invalidation
tailwindcss 4 + @tailwindcss/vite Utility CSS with @theme design tokens
@tailwindcss/typography Prose styling for long-form content
@radix-ui/react-dialog, -dropdown-menu, -slot Accessible unstyled UI primitives
class-variance-authority Typed component variants
clsx + tailwind-merge Class composition and conflict resolution
lucide-react Icon set
zod 4 Env, form, and shared validation
@fontsource-variable/inter, -lora Self-hosted variable fonts
fontaine Metric-matched font fallbacks (zero CLS)
typescript 6 Static typing
vitest + @testing-library/react + jsdom Unit/component tests
eslint 9 (@tanstack/eslint-config, simple-import-sort, unicorn, unused-imports) Linting
prettier 3 + prettier-plugin-tailwindcss Formatting + class sorting

Server

Library Role
express 4 HTTP framework
typescript 6 Static typing
tsx Dev runtime with watch
tsc-alias Rewrites path aliases in the build output
@supabase/supabase-js Database + auth client (service role)
zod 4 Request validation
helmet Security headers
cors Cross-origin policy
morgan Request logging
express-rate-limit Rate limiting
multer Multipart upload handling
dotenv Env loading

Workspace

Library Role
pnpm workspace Single install for client + server, shared hooks
husky 9 Git hook activation
@commitlint/cli + config-conventional Conventional Commit enforcement
lint-staged Auto-fix staged files pre-commit

What the migration bought, measurably

  • Type safety end to endpnpm typecheck (client and server) and generated Supabase types catch contract drift before runtime.
  • One quality gatepnpm check runs lint + typecheck + tests + format on both packages; pre-commit blocks unformatted code; commit-msg blocks malformed history.
  • Smaller, lazier bundlesautoCodeSplitting ships one chunk per route instead of one monolithic script.
  • Zero cumulative layout shift on first paint via fontaine fallbacks.
  • Reusable UI — a single design-system layer replaces per-page markup, so a button change lands everywhere at once.

Related docs

  • CHANGELOG.md[2.0.0] frontend rewrite entry with full Added/Changed/Removed.
  • docs/pnpm-workspace-migration.md — the workspace consolidation.
  • client/docs/tooling-plan.md — client tooling design notes.
  • client/docs/migration-shared-components.md — component extraction notes.
  • server/docs/system-design-case-study.md — server architecture rationale.
  • server/docs/api/endpoints.md — API reference the client consumes.