refactor: add cross-platform utility functions

This commit is contained in:
Haileyesus
2026-03-17 10:19:50 +03:00
parent 23c39a42b1
commit 7df21556dd
16 changed files with 872 additions and 0 deletions

View File

@@ -22,6 +22,12 @@ server/
error-handler.ts
not-found-handler.ts
request-context.ts
platform/
runtime-platform.ts
text.ts
stream.ts
shell.ts
path.ts
types/
app.ts
http.ts
@@ -80,6 +86,11 @@ server/
Example: `async-handler.ts` removes repeated `try/catch(next)` wrappers in controllers.
Example: `not-found-handler.ts` is the generic fallback for unknown API routes.
- `src/shared/platform/`
Shared OS-adapter helpers for shell spawning, line ending normalization, streaming stdout/stderr parsing, and path normalization.
Example: `platform/stream.ts` is where process output gets split into complete lines without leaking CRLF edge cases into feature code.
Example: `platform/shell.ts` is where PowerShell-vs-bash command construction lives so provider modules do not branch on `process.platform`.
- `src/shared/types/`
Global type aliases that are safe to share across modules. This layer uses `type`, not `interface`.
Example: `types/http.ts` defines `ApiMeta`, `ApiErrorShape`, `RequestContext`, `AuthenticatedRequest`, and `EndpointInventoryRecord`.