0.0.2-RC.0 • Published 1 year ago

@enhance/core v0.0.2-RC.0

Weekly downloads
-
License
-
Repository
-
Last release
1 year ago

!WARNING
This work is in progress!

WIP: @enhance/app-core "Core"

goals

mainly:

Create an intermediary library between @enhance/arc-plugin-enhance and @enhance/ssr

  • scope: create router from pre-loaded routes Map. marshall pre-defined element functions. return a method routeAndRender() that does:
    • req → { route, execute api, render template, return } → result
  • Agnostic to Architect (mostly - see below about i/o)
    • this library doesn't consider many Arc things or Arc-specific parts of arc-plugin-enhance.
  • more easily tested
  • adaptable to other Node.js servers - even other runtimes like Deno and the browser
    • there are no Node.js dependencies in this library

also...

  • use @architect/function#http-style input and output
    • adapters could be used to convert to/from other formats like native IncomingMessage and ServerResponse - the advantag here is that implementation is above Core
  • outsource routing to external dep (not a hard requirement, but many benefits)
    • will require some adapting to fit Enhance path param API
  • don't swallow user-land exceptions
    • the Core consumer can handle errors as it sees fit
  • Core router doesn't render errors, just throws
    • only throws on missing or incomplete route: err.message is "404"
    • if user-land code throws, log the exception and throw
  • don't search for head file - but allow it to be provided
  • don't load state for api fn (so no preflight)
    • but allow additional state at request-time for routeAndRender()
    • also allow initial router state to be provided
  • expose decent type defs for configuration and returned values

notes

  • the main method is routeAndRender(), but render() is also very helpful
    • and elements override in render() could be a perf vector
  • the radix3 router (currently implemented) is a good router candidate
    • it will never be a bottleneck
    • but it uses : to denote params, Enhance uses $

next

  • fix session and state passing
  • handle path params
  • add middleware considerations
  • expand options/config to allow pre-loaded routes, handlers, pages, and elements
  • swap linter config
  • drop into existing arc-plugin-enhance as sidecar, run tests

samples

check out the smoke-test for a few examples of how to use this library

0.1.0-alpha.0

1 year ago

0.0.3-RC.1

1 year ago

0.0.3-RC.2

1 year ago

0.0.3-RC.3

1 year ago

0.0.3-RC.0

1 year ago

0.0.2-RC.0

1 year ago