Skip to content

Latest commit

 

History

History
123 lines (81 loc) · 4.63 KB

File metadata and controls

123 lines (81 loc) · 4.63 KB

← Back to README

m7Fetch — Usage Guide (Table of Contents)

  • What m7Fetch is, supported runtimes (browser/ESM/Node), and when to use Net vs. bare HTTP.
  • Key features at a glance: HTTP client, OpenAPI/custom specs, dynamic modules, batch/coordination.
  • Getting the source into your project; recommended folder layout (alongside M7BootStrap).
  • Minimal sanity check: instantiate Net and perform a simple GET.
  • Create a Net instance.
  • Make a GET and POST request.
  • Load an OpenAPI spec and call an operation by operationId.
  • Dynamically import a JS module via Net.modules.
  • Net hub: composition of http, specs, modules, and batch.
  • HTTP client: base URL resolution, JSON/urlencoded bodies, response formats.
  • Specs: load OpenAPI/custom specs; dispatch by operationId.
  • Modules: dynamic imports with simple registry.
  • Batch/Sync loaders: coordinate many requests with concurrency control.
  • class Net(opts) — constructor, subsystems, and lifecycle.
  • class HTTP — methods, option parsing, and response formats.
  • specs.load(...) / specs.call(...) — loading and invoking operations.
  • modules.load(id, url) — registering & importing modules.
  • batch.run(loadList, onLoad, onFail, { awaitAll, limit }) — orchestration entrypoint.
  • Methods: get, post, put, patch, delete, head, options.
  • Building URLs (base vs. absolute), headers, query params.
  • Bodies: JSON, URL-encoded, FormData, text, blobs.
  • Response formats: body | full | raw; parsing JSON/text/blob.
  • Timeouts and AbortController notes.
  • Per-instance vs. per-request options; merge behavior.
  • HTTP.FETCH_DEFAULTS — extending global defaults (e.g., credentials, mode).
  • Allowed fetch enums: mode, cache, credentials, redirect, referrerPolicy, etc.
  • Loading specs from URL, inline objects, or typed loaders.
  • Calling operations by operationId; method/path resolution.
  • Inferring request/response options from spec metadata.
  • Dispatch by spec type (x-type/conventions); GET vs. POST with payload.
  • How options propagate to HTTP layer.
  • Registering modules by ID and URL; accessing exports.
  • Caching/invalidations; error handling patterns.
  • BatchLoader.run(...): ID-keyed jobs, concurrency limit, { awaitAll, limit } behavior.
  • Failure semantics: only false marks a request as failed.
  • context[id] result storage; when to use custom handlers.
  • SyncLoader: require(), wrapper(), loaded()/failed()/success() states.
  • Writing custom batch handlers (store/validate/transform).
  • Passing headers (e.g., Authorization) and credential modes.
  • CORS considerations; origin and cookie handling.
  • Choosing format: "full" for status/headers/body.
  • Preflight validation: duplicate IDs, unsupported methods.
  • Using a debug logger/hook during development.
  • Built-in limiter used by BatchLoader.
  • Tuning limit and tradeoffs (throughput vs. back-pressure).
  • Plain HTTP usage: GET/POST with full responses.
  • OpenAPI spec load + operationId call.
  • Custom batch handler (validate/store/transform).
  • Dynamic module load and invocation.
  • Common pitfalls and fixes:

    • Duplicate batch IDs
    • Invalid/unsupported HTTP methods
    • Missing or mismatched spec type
    • Non-object spec payloads
    • Interpreting false correctly in handlers
  • Net, HTTP, SpecManager, AutoLoader, ModuleManager, BatchLoader, SyncLoader, FETCH_DEFAULTS, format.
  • MTL-10 summary: permitted vs. restricted use.
  • Scope of AI assistance for docs/code and review process.
  • Versioned changes (API additions, behavior tweaks, deprecations).