@flancer32/teq-web 0.4.0 → 0.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (46) hide show
  1. package/CHANGELOG.md +30 -0
  2. package/README.md +236 -127
  3. package/ai/AGENTS.md +36 -0
  4. package/ai/abstractions.md +75 -0
  5. package/ai/examples/minimal-server.md +79 -0
  6. package/ai/overview.md +29 -0
  7. package/ai/rules.md +44 -0
  8. package/package.json +43 -37
  9. package/src/Back/Api/Handler.mjs +26 -0
  10. package/src/Back/Config/Runtime/Tls.mjs +89 -0
  11. package/src/Back/Config/Runtime.mjs +114 -0
  12. package/src/Back/Dto/Info.mjs +62 -0
  13. package/src/Back/Dto/RequestContext.mjs +33 -0
  14. package/src/Back/Dto/{Handler/Source.js → Source.mjs} +24 -25
  15. package/src/Back/Enum/Server/Type.mjs +13 -0
  16. package/src/Back/Enum/Stage.mjs +13 -0
  17. package/src/Back/Handler/Pre/Log.mjs +55 -0
  18. package/src/Back/Handler/Static/A/{Config.js → Config.mjs} +11 -4
  19. package/src/Back/Handler/Static/A/{Fallback.js → Fallback.mjs} +12 -4
  20. package/src/Back/Handler/Static/A/{FileService.js → FileService.mjs} +30 -17
  21. package/src/Back/Handler/Static/A/{Registry.js → Registry.mjs} +15 -7
  22. package/src/Back/Handler/Static/A/{Resolver.js → Resolver.mjs} +10 -3
  23. package/src/Back/Handler/Static.mjs +79 -0
  24. package/src/Back/Helper/Cast.mjs +116 -0
  25. package/src/Back/Helper/{Mime.js → Mime.mjs} +2 -0
  26. package/src/Back/Helper/Order/Kahn.mjs +69 -0
  27. package/src/Back/Helper/{Respond.js → Respond.mjs} +14 -7
  28. package/src/Back/Logger.mjs +57 -0
  29. package/src/Back/PipelineEngine.mjs +216 -0
  30. package/src/Back/{Server.js → Server.mjs} +38 -30
  31. package/types.d.ts +45 -22
  32. package/src/AGENTS.md +0 -108
  33. package/src/Back/Api/Handler.js +0 -26
  34. package/src/Back/Defaults.js +0 -6
  35. package/src/Back/Dispatcher.js +0 -115
  36. package/src/Back/Dto/Handler/Info.js +0 -68
  37. package/src/Back/Enum/Server/Type.js +0 -12
  38. package/src/Back/Enum/Stage.js +0 -10
  39. package/src/Back/Handler/Pre/Log.js +0 -45
  40. package/src/Back/Handler/Static.js +0 -63
  41. package/src/Back/Helper/Cast.js +0 -114
  42. package/src/Back/Helper/Order/Kahn.js +0 -66
  43. package/src/Back/Logger.js +0 -53
  44. package/src/Back/Server/Config/Tls.js +0 -55
  45. package/src/Back/Server/Config.js +0 -69
  46. package/teqfw.json +0 -8
package/CHANGELOG.md CHANGED
@@ -1,5 +1,35 @@
1
1
  # Changelog
2
2
 
3
+ ## [0.6.0] - 2026-03-16 - Runtime configuration hardening
4
+
5
+ ### Added
6
+ - Added JSDoc coverage for request-context DTO usage and runtime configuration components.
7
+
8
+ ### Changed
9
+ - Refined runtime configuration composition for server and TLS settings.
10
+ - Hardened runtime configuration objects to remain immutable after initialization.
11
+ - Updated package version metadata to `0.6.0`.
12
+
13
+ ## [0.5.0] - 2026-03-13
14
+
15
+ ### Added
16
+ - Added `ai/` documentation for agent-oriented project materials.
17
+ - Added a non-resettable request-context attribute.
18
+ - Added component type conventions to the cognitive context.
19
+
20
+ ### Changed
21
+ - Updated `README.md` with package and agent-interface documentation refinements.
22
+ - Migrated dependency injection to `@teqfw/di` v2 and updated package metadata accordingly.
23
+ - Refined architecture and terminology around the dispatcher, request context, and transport boundary.
24
+ - Reworked source files to codex-generated module layout and aligned exported namespace style with the `$` convention.
25
+ - Verified modules in `src/` against updated TeqFW ES module conventions and aligned DTO component types with those rules.
26
+ - Restructured and cleaned up `ctx/docs`, including TeqFW convention documents and removal of the obsolete composition level.
27
+ - Moved the accept test into the integration test suite.
28
+ - Refreshed runtime and development dependencies.
29
+
30
+ ### Removed
31
+ - Removed legacy code, tests, and the shared `common.mjs` unit-test helper.
32
+
3
33
  ## [0.4.0] - 2025-12-20
4
34
 
5
35
  ### Added
package/README.md CHANGED
@@ -1,152 +1,240 @@
1
1
  # @flancer32/teq-web
2
2
 
3
- **@flancer32/teq-web** is a modular request dispatcher and web server for Node.js applications.
4
- It follows the principles of the [TeqFW](https://github.com/flancer32/teqfw) architecture but works independently and
5
- can be integrated into any Node.js project.
6
- The plugin offers a flexible, pluggable HTTP/2-capable server with three-stage handler processing and dependency-driven
7
- execution order.
3
+ Infrastructure web server and deterministic request pipeline for TeqFW packages.
8
4
 
9
- ---
5
+ `@flancer32/teq-web` is an infrastructural component of the **Tequila Framework (TeqFW)** platform.
6
+
7
+ The package provides a deterministic **request lifecycle pipeline** and a built-in **Node.js web server** that other TeqFW packages can use as the runtime environment for processing HTTP requests.
8
+
9
+ Within the TeqFW ecosystem, this package plays a role similar to how **Express** or **Fastify** are used in typical Node.js applications: it acts as the **web runtime layer** used by higher-level packages.
10
+
11
+ Unlike general-purpose web frameworks, this package focuses only on coordinating **request lifecycle execution through a deterministic handler pipeline**.
12
+
13
+ The package requires the dependency container **@teqfw/di**.
14
+
15
+ Platform website: <https://teqfw.com/>
10
16
 
11
17
  ## Overview
12
18
 
13
- This package provides:
19
+ The package provides infrastructure for processing web requests inside a TeqFW application.
20
+
21
+ Core responsibilities:
22
+
23
+ - deterministic **request lifecycle coordination**
24
+ - ordered **handler execution pipeline**
25
+ - **Node.js server integration** (`http`, `http2`, `https`)
26
+ - **handler registration metadata**
27
+ - **static file handler**
28
+ - DTO factories and enums used by handler implementations
29
+
30
+ The package does **not** provide:
31
+
32
+ - routing frameworks
33
+ - controllers
34
+ - application architecture
35
+ - persistence
36
+ - session management
37
+ - business logic abstractions
38
+
39
+ Its sole responsibility is coordinating the **lifecycle of a web request**.
40
+
41
+ ## Role in the TeqFW Ecosystem
42
+
43
+ | Layer | Responsibility |
44
+ | -------------------- | ----------------------------------------- |
45
+ | Application packages | business logic, handlers |
46
+ | `@flancer32/teq-web` | web server and request lifecycle pipeline |
47
+ | `@teqfw/di` | runtime dependency linking |
48
+
49
+ TeqFW applications are composed of multiple packages that declare dependencies through the DI container.
50
+
51
+ `@flancer32/teq-web` provides the **web runtime layer** in which those packages handle incoming requests.
52
+
53
+ ## Request Lifecycle
54
+
55
+ Each request is processed through a fixed three-stage pipeline:
56
+
57
+ ```text
58
+ INIT → PROCESS → FINALIZE
59
+ ```
14
60
 
15
- - A **dispatcher** that processes HTTP requests in three well-defined stages: `pre`, `process`, `post`.
16
- - A **handler interface** for modular request handling across plugins or components.
17
- - A **built-in server** based on Node.js libraries (`http`, `http2`), supporting TLS via `http2.createSecureServer()`.
18
- - Support for **relative handler ordering** using `before` / `after` declarations and topological sorting.
19
- - Compatibility with **external servers** like Express/Fastify by using the dispatcher as middleware.
20
- - Minimal dependencies and full support for dependency injection via `@teqfw/di`.
61
+ Stage semantics:
21
62
 
22
- ---
63
+ | Stage | Purpose |
64
+ | -------- | ------------------------------------------------- |
65
+ | INIT | request preparation (logging, enrichment, guards) |
66
+ | PROCESS | request handling |
67
+ | FINALIZE | cleanup and post-processing |
23
68
 
24
- ## Architecture
69
+ Processing stops when a `PROCESS` handler marks the request as completed.
25
70
 
26
- The dispatcher runs HTTP requests through a consistent three-phase pipeline:
71
+ If no handler handles the request, the system produces **404 Not Found**.
27
72
 
28
- 1. **Pre-processing (`pre`)** — All handlers are executed in a defined order (e.g., logging, authentication).
29
- 2. **Processing (`process`)** — Handlers are checked sequentially until one returns `true` (request handled).
30
- 3. **Post-processing (`post`)** — All handlers are executed unconditionally, even after errors.
73
+ ## Core Components
31
74
 
32
- Each handler provides its registration metadata via the `getRegistrationInfo()` method. Execution order is resolved with
33
- a built-in implementation of Kahn's algorithm.
75
+ ### Pipeline Engine
34
76
 
35
- Example handler definition:
77
+ The **Pipeline Engine** is the single lifecycle coordination authority.
36
78
 
37
- ```js
38
- const My_Handler = {
39
- getRegistrationInfo: () => Object.freeze({
40
- name: 'My_Handler',
41
- stage: 'process', // can be 'pre', 'process', or 'post'
42
- before: [],
43
- after: [],
44
- }),
79
+ Responsibilities:
45
80
 
46
- handle: async (req, res) => {
47
- res.writeHead(200, {'Content-Type': 'text/plain'});
48
- res.end('Hello from My_Handler!');
49
- return true;
50
- },
81
+ - handler registration
82
+ - deterministic handler ordering
83
+ - request lifecycle execution
84
+ - request completion control
85
+ - runtime error handling
86
+
87
+ Handlers are ordered based on declarative metadata (`before` / `after` constraints).
88
+
89
+ ### Server
90
+
91
+ The built-in server connects the Node.js transport layer to the request pipeline.
92
+
93
+ Supported server types:
94
+
95
+ - `http`
96
+ - `http2`
97
+ - `https`
98
+
99
+ The server locks the handler pipeline before entering the execution phase.
100
+
101
+ ### Handlers
102
+
103
+ Handlers are independent modules participating in request processing.
104
+
105
+ Each handler provides registration metadata:
106
+
107
+ - unique handler name
108
+ - execution stage
109
+ - relative ordering constraints
110
+
111
+ Handlers do not coordinate with each other directly. Execution order is derived from metadata and is deterministic.
112
+
113
+ ## Example (TeqFW Style)
114
+
115
+ ```javascript
116
+ // App/Web/Handler/Hello.mjs
117
+
118
+ export const __deps__ = {
119
+ dtoInfoFactory: "Fl32_Web_Back_Dto_Info__Factory$",
120
+ STAGE: "Fl32_Web_Back_Enum_Stage$",
51
121
  };
52
122
 
53
- export default My_Handler;
54
- ````
55
-
56
- ---
57
-
58
- ## Usage
59
-
60
- This example shows how to create a minimal application that:
61
-
62
- * Registers two handlers: a logger and a static file server
63
- * Starts a secure HTTPS server using built-in components
64
-
65
- The static handler reads from one or more **sources** described by the
66
- `Handler_Source` DTO. To expose selected files from `node_modules`, create a
67
- source with `root: 'node_modules'` and pass it to `Handler_Static` during
68
- initialization.
69
-
70
- ```js
71
- import Container from '@teqfw/di';
72
- import {readFileSync} from 'node:fs';
73
- import {join, resolve} from 'node:path';
74
- import {fileURLToPath} from 'node:url';
75
-
76
- // Resolve working directory
77
- const __filename = fileURLToPath(import.meta.url);
78
- const __dirname = resolve(__filename, '..');
79
- const webRoot = join(__dirname, 'web');
80
- const certs = join(__dirname, 'certs');
81
-
82
- // DI container setup
83
- const container = new Container();
84
- const resolver = container.getResolver();
85
- resolver.addNamespaceRoot('Fl32_Web_', './node_modules/@flancer32/teq-web/src');
86
-
87
- // Get and configure built-in handlers
88
- const logHandler = await container.get('Fl32_Web_Back_Handler_Pre_Log$');
89
- const staticHandler = await container.get('Fl32_Web_Back_Handler_Static$');
90
- const SourceCfg = await container.get('Fl32_Web_Back_Dto_Handler_Source$');
91
- const srcNpm = SourceCfg.create({
92
- root: 'node_modules',
93
- prefix: '/node_modules/',
94
- allow: {
95
- vue: ['dist/vue.global.prod.js'],
96
- '@teqfw/di': ['src/Container.js'],
97
- }
98
- });
99
- const srcWeb = SourceCfg.create({ root: webRoot, prefix: '/' });
100
- await staticHandler.init({sources: [srcNpm, srcWeb]});
101
-
102
- // Register handlers
103
- const dispatcher = await container.get('Fl32_Web_Back_Dispatcher$');
104
- dispatcher.addHandler(logHandler);
105
- dispatcher.addHandler(staticHandler);
106
-
107
- // Create and start the server
108
- const server = await container.get('Fl32_Web_Back_Server$');
109
- await server.start({
110
- port: 3443,
111
- type: 'https',
112
- tls: {
113
- key: readFileSync(join(certs, 'key.pem'), 'utf8'),
114
- cert: readFileSync(join(certs, 'cert.pem'), 'utf8'),
115
- ca: readFileSync(join(certs, 'ca.pem'), 'utf8'),
116
- }
117
- });
123
+ export default class App_Web_Handler_Hello {
124
+ constructor({ dtoInfoFactory, STAGE }) {
125
+ const info = dtoInfoFactory.create({
126
+ name: "App_Web_Handler_Hello",
127
+ stage: STAGE.PROCESS,
128
+ });
129
+
130
+ this.getRegistrationInfo = () => info;
131
+
132
+ this.handle = async function (context) {
133
+ const { response } = context;
134
+
135
+ response.writeHead(200, { "Content-Type": "text/plain" });
136
+ response.end("ok");
137
+
138
+ context.complete();
139
+ };
140
+ }
141
+ }
142
+ ```
143
+
144
+ ```javascript
145
+ // App/Web/Server/Start.mjs
146
+
147
+ export const __deps__ = {
148
+ pipeline: "Fl32_Web_Back_PipelineEngine$",
149
+ server: "Fl32_Web_Back_Server$",
150
+ helloHandler: "App_Web_Handler_Hello$",
151
+ };
152
+
153
+ export default class App_Web_Server_Start {
154
+ constructor({ pipeline, server, helloHandler }) {
155
+ this.execute = async function () {
156
+ pipeline.addHandler(helloHandler);
157
+
158
+ await server.start({
159
+ port: 3000,
160
+ type: "http",
161
+ });
162
+ };
163
+ }
164
+ }
165
+ ```
166
+
167
+ Application entry point:
168
+
169
+ ```javascript
170
+ const app = await container.get("App_Web_Server_Start$");
171
+ await app.execute();
118
172
  ```
119
173
 
120
- This will start an HTTPS server on port `3443` with:
174
+ ## Designed for Development with LLM Agents
175
+
176
+ TeqFW is an architectural approach designed for software development in which **LLM agents participate directly in the development process**.
177
+
178
+ Traditional software architectures assume that all code is written and maintained by humans.
179
+
180
+ TeqFW assumes a different workflow:
181
+
182
+ - humans design the **architecture and specifications**
183
+ - LLM agents generate and maintain the **implementation**
184
+
185
+ To support this workflow, TeqFW structures applications so they are easier for automated agents to analyze and modify.
186
+
187
+ Key design principles include:
188
+
189
+ - explicit dependency contracts
190
+ - deterministic runtime linking
191
+ - predictable module structure
192
+ - namespace-based component addressing
193
+ - minimal hidden coupling between modules
194
+
195
+ This allows systems to be more reliably:
121
196
 
122
- * `Fl32_Web_Back_Handler_Pre_Log` logging each request method and URL;
123
- * `Fl32_Web_Back_Handler_Static` serving files from `node_modules` and the `/web` folder.
197
+ - analyzed
198
+ - generated
199
+ - refactored
200
+ - extended
124
201
 
125
- ---
202
+ by both **human developers and AI agents**.
126
203
 
127
- ### Using with Express or Fastify
204
+ ## Agent-Driven Implementation
128
205
 
129
- The dispatcher can be connected to external web frameworks instead of the built-in server.
206
+ TeqFW libraries are developed using **Agent-Driven Software Management (ADSM)**, a methodology created by **Alex Gusev**.
130
207
 
131
- ```js
132
- // Express
133
- const app = Express();
134
- app.use(async (req, res) => {
135
- await dispatcher.onEventRequest(req, res);
136
- });
137
- app.listen(3000);
208
+ The workflow is:
138
209
 
139
- // Fastify
140
- const fastify = Fastify();
141
- fastify.all('*', async (request, reply) => {
142
- const req = request.raw;
143
- const res = reply.raw;
144
- await dispatcher.onEventRequest(req, res);
145
- });
146
- await fastify.listen({port: 3000});
210
+ 1. A human architect defines the **product model and specifications**
211
+ 2. **LLM agents (Codex)** generate the implementation
212
+ 3. The human architect reviews and integrates the generated code
213
+
214
+ This package is part of that experiment and demonstrates how **human-designed architecture can be implemented by AI agents**.
215
+
216
+ ## Agent Interface
217
+
218
+ This package includes **agent interface documentation** intended for LLM agents that use the library as a dependency.
219
+
220
+ These documents are distributed inside the package in:
221
+
222
+ ```text
223
+ ./ai/
147
224
  ```
148
225
 
149
- ---
226
+ For a quick integration reference, see:
227
+
228
+ - `ai/examples/minimal-server.md`
229
+
230
+ They describe:
231
+
232
+ - runtime abstractions
233
+ - request lifecycle semantics
234
+ - handler contracts
235
+ - integration rules for TeqFW applications
236
+
237
+ Human developers typically read the README and source code, while **LLM agents can rely on the documentation in `./ai/`.**
150
238
 
151
239
  ## Installation
152
240
 
@@ -154,11 +242,32 @@ await fastify.listen({port: 3000});
154
242
  npm install @flancer32/teq-web
155
243
  ```
156
244
 
157
- This plugin requires a configured `@teqfw/di` container and optionally integrates with TeqFW-based apps.
245
+ The package requires a configured `@teqfw/di` container.
246
+
247
+ ## Tequila Framework
248
+
249
+ `@flancer32/teq-web` is part of the **Tequila Framework (TeqFW)** ecosystem.
250
+
251
+ More information about the platform:
252
+ [https://teqfw.com/](https://teqfw.com/)
253
+
254
+ TeqFW is an experimental platform exploring how software architecture changes when **AI agents become active participants in the development process**.
255
+
256
+ Key architectural ideas include:
257
+
258
+ - modular monolith architecture
259
+ - runtime dependency linking
260
+ - namespace-based component addressing
261
+ - pure JavaScript without compilation
262
+ - system structures optimized for collaboration with LLM agents
263
+
264
+ ## Author
265
+
266
+ **Alex Gusev**
158
267
 
159
- ---
268
+ Creator of:
160
269
 
161
- ## Status
270
+ - **Tequila Framework (TeqFW)**
271
+ - **ADSM (Agent-Driven Software Management)**
162
272
 
163
- This package is under active development and already used in real-world applications. Documentation is built using the
164
- **3DP** method (Dialog-Driven Development Process) and evolves alongside actual use cases.
273
+ This project explores how software architecture evolves when **LLM agents become active participants in the development process**.
package/ai/AGENTS.md ADDED
@@ -0,0 +1,36 @@
1
+ # AGENTS.md
2
+
3
+ Version: 20260311
4
+
5
+ ## Package Purpose
6
+
7
+ This directory provides the Agent Interface of `@flancer32/teq-web`. It contains a compact usage-oriented projection of the package intended for LLM agents that consume the package as a dependency inside TeqFW applications.
8
+
9
+ The interface describes how external code should use the package and excludes repository organization, development workflow, testing strategy, and other internal project concerns.
10
+
11
+ ## TeqFW Usage Model
12
+
13
+ `@flancer32/teq-web` is designed for TeqFW-style runtime composition with `@teqfw/di`.
14
+
15
+ Dependencies should be linked through Canonical Dependency Codes and constructor injection rather than through direct static imports between application modules. External code should treat the package as infrastructure resolved by the container:
16
+
17
+ - application modules declare dependencies through `__deps__`;
18
+ - the container resolves `Fl32_Web_*` identifiers at runtime;
19
+ - orchestration is performed inside DI-managed application services;
20
+ - handlers and server components are configured before the server enters execution phase.
21
+
22
+ ## Reading Order
23
+
24
+ Agents should read the documents in this directory in the following order:
25
+
26
+ 1. `AGENTS.md` — overview of the agent interface and navigation.
27
+ 2. `overview.md` — package role, intended usage boundary, and main entry points.
28
+ 3. `abstractions.md` — core runtime concepts and consumer-facing abstractions.
29
+ 4. `rules.md` — mandatory usage constraints and invariants.
30
+ 5. `examples/minimal-server.md` — minimal TeqFW-style orchestration example.
31
+
32
+ ## Interface Scope
33
+
34
+ The documents in this directory define only the supported usage semantics relevant to package consumers. Behaviors not described here should be treated as undefined and should not be inferred from internal implementation details.
35
+
36
+ Internal helper modules and deep implementation paths are outside the preferred consumer interface unless a task explicitly requires them.
@@ -0,0 +1,75 @@
1
+ # Core Abstractions
2
+
3
+ ## Pipeline Engine
4
+
5
+ `Fl32_Web_Back_PipelineEngine$` is the single lifecycle coordinator. It owns handler registration, derives deterministic order from handler metadata, creates one request context per request, and executes handlers in this fixed order:
6
+
7
+ `INIT -> PROCESS -> FINALIZE`
8
+
9
+ Main methods:
10
+
11
+ - `addHandler(handler)` or `registerHandler(handler)` registers a handler before the pipeline is locked;
12
+ - `lockHandlers()` freezes handler order explicitly;
13
+ - `onEventRequest(req, res)` or `handleRequest(req, res)` executes one request lifecycle.
14
+
15
+ ## Server
16
+
17
+ `Fl32_Web_Back_Server$` is the built-in transport adapter around Node.js `http` and `http2`. On `start(cfg)` it locks the pipeline, creates the server instance, binds request events to the Pipeline Engine, and starts listening.
18
+
19
+ Default transport settings come from `Fl32_Web_Back_Config_Runtime$` under the `server` branch. TLS values for `server.tls` are provided by the dedicated runtime configuration component `Fl32_Web_Back_Config_Runtime_Tls$`. Supported transport modes come from `Fl32_Web_Back_Enum_Server_Type$`:
20
+
21
+ - `http`
22
+ - `http2`
23
+ - `https`
24
+
25
+ `https` requires `server.tls`.
26
+
27
+ ## Handler Contract
28
+
29
+ Custom handlers implement `Fl32_Web_Back_Api_Handler`:
30
+
31
+ - `getRegistrationInfo()` returns handler metadata;
32
+ - `handle(context)` performs work for one request.
33
+
34
+ Handler metadata is created with `Fl32_Web_Back_Dto_Info__Factory$` and contains:
35
+
36
+ - `name`: unique handler name;
37
+ - `stage`: `INIT`, `PROCESS`, or `FINALIZE`;
38
+ - `before`: handler names that must run after this handler;
39
+ - `after`: handler names that must run before this handler.
40
+
41
+ Ordering is resolved once from this metadata and is deterministic within each stage.
42
+
43
+ ## Request Context
44
+
45
+ The Pipeline Engine passes one request-scoped context to every handler. Its stable fields are:
46
+
47
+ - `request`: Node.js request object;
48
+ - `response`: Node.js response object;
49
+ - `data`: mutable per-request shared storage for handlers;
50
+ - `completed`: completion flag;
51
+ - `complete()`: marks request processing as completed;
52
+ - `isCompleted()`: reads the completion state.
53
+
54
+ Handlers may mutate `data` and may read the rest of the context. They must not replace the context object.
55
+
56
+ ## Stage Semantics
57
+
58
+ - `INIT`: always runs first; use for setup, logging, request enrichment, or guard preparation.
59
+ - `PROCESS`: runs until completion is marked; use for actual request handling.
60
+ - `FINALIZE`: always runs last; use for cleanup and post-processing.
61
+
62
+ Only `PROCESS` handlers may mark the request as completed.
63
+
64
+ ## Built-in Static Handler
65
+
66
+ `Fl32_Web_Back_Handler_Static$` is a PROCESS-stage handler for static file delivery. Before use, call `init({sources})` with source DTOs created by `Fl32_Web_Back_Dto_Source$Factory`.
67
+
68
+ Each source describes:
69
+
70
+ - `root`: filesystem root;
71
+ - `prefix`: URL prefix matched by the handler;
72
+ - `allow`: optional allowlist map for paths under the source;
73
+ - `defaults`: optional fallback filenames for directory requests.
74
+
75
+ If the static handler serves a file successfully, it marks the request as completed.
@@ -0,0 +1,79 @@
1
+ # Minimal Server Example
2
+
3
+ This example shows the preferred TeqFW-style usage path: external code resolves one application service from the container, and that service receives web infrastructure through constructor injection.
4
+
5
+ ```js
6
+ // App/Web/Handler/Hello.mjs
7
+ // @ts-check
8
+
9
+ export const __deps__ = {
10
+ dtoInfoFactory: 'Fl32_Web_Back_Dto_Info__Factory$',
11
+ STAGE: 'Fl32_Web_Back_Enum_Stage$',
12
+ };
13
+
14
+ export default class App_Web_Handler_Hello {
15
+ /**
16
+ * @param {{
17
+ * dtoInfoFactory: Fl32_Web_Back_Dto_Info$Factory,
18
+ * STAGE: Fl32_Web_Back_Enum_Stage,
19
+ * }} deps
20
+ */
21
+ constructor({dtoInfoFactory, STAGE}) {
22
+ const info = dtoInfoFactory.create({
23
+ name: 'App_Web_Handler_Hello',
24
+ stage: STAGE.PROCESS,
25
+ });
26
+
27
+ this.getRegistrationInfo = () => info;
28
+
29
+ this.handle = async function (context) {
30
+ const {response} = context;
31
+ response.writeHead(200, {'Content-Type': 'text/plain; charset=utf-8'});
32
+ response.end('ok');
33
+ context.complete();
34
+ };
35
+ }
36
+ }
37
+ ```
38
+
39
+ ```js
40
+ // App/Web/Server/Start.mjs
41
+ // @ts-check
42
+
43
+ export const __deps__ = {
44
+ pipeline: 'Fl32_Web_Back_PipelineEngine$',
45
+ server: 'Fl32_Web_Back_Server$',
46
+ helloHandler: 'App_Web_Handler_Hello$',
47
+ };
48
+
49
+ export default class App_Web_Server_Start {
50
+ /**
51
+ * @param {{
52
+ * pipeline: Fl32_Web_Back_PipelineEngine,
53
+ * server: Fl32_Web_Back_Server,
54
+ * helloHandler: App_Web_Handler_Hello,
55
+ * }} deps
56
+ */
57
+ constructor({pipeline, server, helloHandler}) {
58
+ this.execute = async function () {
59
+ pipeline.addHandler(helloHandler);
60
+ await server.start({port: 3000, type: 'http'});
61
+ };
62
+ }
63
+ }
64
+ ```
65
+
66
+ ```js
67
+ // composition root
68
+ const app = await container.get('App_Web_Server_Start$');
69
+ await app.execute();
70
+ ```
71
+
72
+ Consumer notes:
73
+
74
+ - The composition root configures namespace roots once and resolves one application entry service.
75
+ - Application modules do not construct collaborators directly and do not call `new` for DI-managed handlers or infrastructure services.
76
+ - `server.start()` locks handler registration for the runtime lifetime of that server instance.
77
+ - Built-in server defaults may also be supplied through `Fl32_Web_Back_Config_Runtime__Factory$` as `{server: {port, type, tls}}`, where `tls` is owned by the runtime component `Fl32_Web_Back_Config_Runtime_Tls$`.
78
+ - If your application already has its own transport layer, inject `Fl32_Web_Back_PipelineEngine$` and call `pipeline.onEventRequest(req, res)` from that adapter instead of using `Fl32_Web_Back_Server$`.
79
+ - A correct PROCESS handler ends the response and then marks the context completed.
package/ai/overview.md ADDED
@@ -0,0 +1,29 @@
1
+ # Package Overview
2
+
3
+ `@flancer32/teq-web` is server-side request coordination infrastructure for TeqFW applications. It provides a deterministic handler pipeline for web requests and a built-in Node.js server that feeds requests into that pipeline.
4
+
5
+ This package is not a general-purpose web framework. It does not define routing, controllers, domain models, persistence, session handling, or application structure. Its role is limited to coordinating one request lifecycle inside a TeqFW modular monolith.
6
+
7
+ The package assumes `@teqfw/di` and exposes its runtime surface through DI-managed modules under the `Fl32_Web_` namespace rooted at the published `src/` tree. In normal usage, application modules receive these dependencies through constructor injection and orchestrate them from DI-managed services rather than creating containers or wiring collaborators manually inside feature code.
8
+
9
+ Runtime startup configuration is exposed through `Fl32_Web_Back_Config_Runtime$`. Its built-in transport branch is `config.server`, which contains `port`, `type`, and a `tls` branch backed by `Fl32_Web_Back_Config_Runtime_Tls$`.
10
+
11
+ Use this package when external code needs one of these roles:
12
+
13
+ - accept HTTP, HTTPS, or HTTP/2 requests with the built-in server;
14
+ - run request handlers through a fixed three-stage lifecycle;
15
+ - register multiple independent handlers with deterministic ordering;
16
+ - serve static files through the built-in PROCESS-stage handler.
17
+
18
+ Do not use this package as:
19
+
20
+ - a manually wired standalone web platform outside TeqFW DI;
21
+ - a replacement for an application router or MVC framework;
22
+ - a browser, CLI, or serverless runtime component.
23
+
24
+ The main consumer entry points are:
25
+
26
+ - `Fl32_Web_Back_PipelineEngine$` for request lifecycle coordination;
27
+ - `Fl32_Web_Back_Server$` for the built-in Node.js server;
28
+ - `Fl32_Web_Back_Api_Handler` plus `Fl32_Web_Back_Dto_Info__Factory$` and `Fl32_Web_Back_Dto_Info` for custom handlers;
29
+ - `Fl32_Web_Back_Handler_Static$` plus `Fl32_Web_Back_Dto_Source` values for static file serving.