Introduce backend-utils Option for Modern Server Scaffolding#210
Open
AyushBhagat151105 wants to merge 6 commits into
Open
Introduce backend-utils Option for Modern Server Scaffolding#210AyushBhagat151105 wants to merge 6 commits into
AyushBhagat151105 wants to merge 6 commits into
Conversation
…solver, simplify MCP setup
…ectories for tests
|
@AyushBhagat151105 is attempting to deploy a commit to the Ibrahim's projects Team on Vercel. A member of the Team first needs to authorize it. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Goal & Overview
This Pull Request introduces the
backend-utilsoption to the TypeScript ecosystem. This feature provides scaffolded projects with production-grade utilities for HTTP responses, async route handling, global error management, and standard health checks. It fully supports and integrates with all core backend frameworks including Hono, Express, Elysia, Fastify, feTS, and NestJS.Additionally, this PR refines CLI integration tests by adding robust isolation for system paths (home directory, app data) to prevent tests from writing into or leaking from the user's real host directories, specifically addressing Windows-specific path issues.
Key Features & Proposed Changes
1. Schema & Stack Configuration
backendUtilscategory to option metadata (packages/types/src/option-metadata.ts) with appropriate branding labels.apps/web/src/lib/stack-project-config-base.ts), templates, fixtures, and documentation schemas.backend-utilsoption on the web platform (apps/web/content/docs/ecosystems/typescript.mdxand reference directories).2. Interactive CLI Prompts
resolveBackendUtilsPromptinapps/cli/src/prompts/backend-utils.tsto intelligently prompt when a compatible backend is chosen (Hono, Express, Elysia, Fastify, etc.) and auto-default tononefor incompatible ones (Convex, AdonisJS, etc.).PROMPT_RESOLVER_REGISTRYinapps/cli/src/prompts/prompt-resolver-registry.ts.createProjectHandlerinapps/cli/src/helpers/core/command-handlers.tsto prevent invalid directory/OS configurations early in execution.3. Core Core Templates & Utility Library (
server/base)We created custom templates under
packages/template-generator/templates/backend-utils/backend-utils/server/base/src/:lib/api-response.ts.hbs: Declares standardHttpStatuscodes and anApiResponsewrapper. It structures standard error and success responses with uniform fields:success(boolean status indicator)statusCode(numerical HTTP status code)message(human-readable message)data(optional cargo)errors(optional field for nested/validation error details)timestamp(ISO standard string)lib/async-handler.ts.hbs: Provides async wrapper helpers tailored to different frameworks (Express, Hono, Fastify, Elysia, NestJS) to safely delegate unhandled exceptions to the framework's native error lifecycles.lib/error-handler.ts.hbs: Standardizes global exceptions:.onErrormiddleware.onErrorplugin handler@Catch()Exception Filter (GlobalExceptionFilter)routes/health.ts.hbs: Provides a standard/healthand/health/readycheck endpoint pre-wired with the newasyncHandlerandApiResponseobjects.4. Framework Integration
Integrated the new middleware and health routes conditionally (
#if (eq backendUtils "backend-utils")) into the entry points of:.onError(errorHandler)and.use(health)router.app.use("/health", health)and finalapp.use(errorHandler)middleware.app.onError(errorHandler)andapp.route("/health", health).app.useGlobalFilters(new GlobalExceptionFilter())and wiredHealthControllerinsideAppModule.5. Testing Infrastructure & Environment Isolation
apps/cli/test/setup.tsandapps/cli/test/add-history-commands.test.ts) by isolating directory paths. Tests now override:HOMEXDG_CONFIG_HOMEXDG_DATA_HOMEAPPDATA(critical for Windows AppData isolation)LOCALAPPDATA(critical for Windows LocalAppData isolation)30sfor complex scenarios to accommodate differing environments.I am open for feedback and review.🚀