feat: beta-hardening — routing, degradation, mesh gate, uploads, @header
Restructure first: split the two oversized files by cohesion (http.ts 449
→ http/{router,request,stream,ws,server,types}; app.ts 556 → app/{types,
introspect,index}), rename cryptic locals, JSDoc the public API, and
extract helpers so no function exceeds the complexity gate (createApp
187 → <15, listen 113 → 6). Public import paths are unchanged (barrels).
On that structure, five features that close the biggest gaps vs
Express/Fastify/Nest for a comparable beta:
- routing: `:name*` catch-all, specificity precedence (static ▸ param ▸
catch-all, not registration order), and 405 + Allow when a path exists
under a different method (was 404)
- visible degradation: optional providers that fail boot are summarized on
listen() and queryable via app.degraded(), instead of a silent warn
- mesh is alpha — gated behind `experimental: true`; createApp throws if
`mesh` is configured without it
- multipart moves to the optional `busboy` peer dependency (clear 501 when
absent), keeping the core at one runtime dependency
- `@header('name')` as a singular alias of `@headers`
Signed-off-by: Diego Resendez <diego.resendez@zero-oneit.com>
This commit is contained in:
42 files changed
+2619
-1170
No files matched your search
@@ -72,8 +72,12 @@ test('optional provider failure warns but does not abort boot', async () => {
|
||||
class SysModule {}
|
||||
|
||||
const app = createApp({ modules: [SysModule] });
|
||||
expect(app.degraded()).toEqual([]); // nothing degraded until boot runs
|
||||
const server = await app.listen(0); // must NOT throw
|
||||
expect(warn).toHaveBeenCalledWith(expect.stringContaining("optional provider 'cache' failed"));
|
||||
// boot ends with a summary of everything running degraded, and it is queryable on the app
|
||||
expect(warn).toHaveBeenCalledWith(expect.stringContaining('started with 1 degraded optional provider(s): cache'));
|
||||
expect(app.degraded()).toEqual(['cache']);
|
||||
server.close();
|
||||
warn.mockRestore();
|
||||
});
|
||||
|
||||
Reference in new issue
Block a user