A Deep Dive into endpoint-plus: A Next-Gen, AI-Native Request Suite A developer open-sourced endpoint-plus, a next-generation AI-native request suite that solves common frontend headaches like manual type definitions and adapter fragmentation. The library introduces a highly abstract transport layer and pluggable middleware pipeline, enabling unified code semantics across different environments such as web, Node SSR, and WeChat Mini-programs. A key feature is compile-time type inference from URL strings, eliminating the need for manual type casting. 💡 GitHub Repository: github.com/zandko/endpoint-plus 🌟 If you find this project helpful or inspiring, please give us aStar We are actively looking for feedback, issues, and PRs to co-create the future of this project. In modern frontend engineering, network requests are much more complex than simply fetching some JSON data. Around every API call, developers must wrestle with four persistent daily headaches: interfaces by hand, or constantly paste them into unstable online formatters. Whenever an API field changes, updating types turns into a maintenance nightmare. fetch or axios . But WeChat Mini-programs and uni-app require proprietary wrapper APIs wx.request or uni.request . Meanwhile, SSR contexts like Nuxt/Next require server-compatible clients. You end up maintaining three separate copies of headers, interceptors, and error handlers.To solve these exact challenges, we built and open-sourced endpoint-plus — a endpoint-plus avoids the monolithic overhead of traditional request clients by introducing a highly abstract physical Transport Layer alongside a pluggable middleware pipeline . php graph TD A API Calls in Application Code -- B endpoint-plus Core Client B -- C Interceptors & Onion-Model Middleware C -- D Transport Layer Interface D -- Web / Node SSR -- E Fetch / Axios Transport D -- Miniapp / uni-app -- F Miniapp Transport B <-- G Vite DevTools Plugin G -- TS Compiler AST Scan -- H Scan Source Code G -- Capture Real Response -- I Schema Inference quicktype I -- J Write local endpoint-types.d.ts By splitting request definition from the actual underlying network implementation, endpoint-plus provides 100% unified code semantics. You simply swap the transport adapter upon client creation: js import { createInstance, createFetchTransport } from 'endpoint-plus'; const api = createInstance { transport: createFetchTransport } ; js import { createMiniappTransport } from 'endpoint-plus/miniapp'; const api = createInstance { transport: createMiniappTransport { runtime: wx } } ; js import { createAxiosTransport } from 'endpoint-plus/transports/axios'; const api = createInstance { transport: createAxiosTransport } ; In addition to traditional request/response interceptors, endpoint-plus introduces a Koa/Express-style Onion-Model Middleware system. This lets you wrap the entire execution lifespan using async functions: js api.registerRequestMiddleware async config, next = { const start = Date.now ; try { // 1. Outer Onion layer: Executed before request dispatch const response = await next config ; // 2. Inner Onion layer: Executed after response resolves console.log Request to ${config.url} took ${Date.now - start}ms ; return response; } catch error { // 3. Centralized error catching and circuit-breaking console.error 'Middleware caught exception:', error ; throw error; } } ; This is the killer type-safety feature of endpoint-plus : You do not need to manually cast generic arguments on every request. TypeScript parses the URL string and infers the correct response type directly at compile-time. For instance, once you declare your routes in a .d.ts file: declare module 'endpoint-plus' { namespace YwEndpoint { interface Routes { 'GET /users': { response: User }; 'GET /users/:userId': { response: User }; 'POST /users': { response: User }; } } } Your editor instantly provides type-safety and autocompletion: js // 🌟 TypeScript 5.0+ const generic parameter pattern matching const userList = await api.get '/users' ; // ^? User Inferred from GET /users const user = await api.get '/users/123' ; // ^? User Even with a concrete ID '123', the parser matches it against ':userId' to return User // ❌ Typos and invalid paths are caught instantly by the compiler const err = await api.get '/usrs' ; // TS Compiler Error We leverage recursive conditional types to strip URL queries, hash anchors, and domain prefixes, parsing the path into segments and pattern-matching them against parameter templates: type EndpointRoutePathMatches< TRoutePath extends string, TUrl extends string, = EndpointPathSegmentsMatch< EndpointSplitPath