Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support ESM import of handler module in default resolver #922

Closed
wants to merge 2 commits into from

Commits on Jun 2, 2024

  1. Support ESM import of handler module in default resolver

    Make the default request handler resolver work in ESM projects by
    allowing a URL value for the handlersPath. If a URL is passed, then
    a dynamic import will be used to load the handler module. If a string is
    passed, then require() will be used.
    
    Because this project uses moduleResolution:node in tsconfig, it's not
    possible to write async import(...) directly in code. It has to be
    obscured so that the compiler does not replace it, hence the HACK!
    function that is essentially eval('import(...)').
    
    ESM users should be aware that a file extension must be specified when
    defining x-eov-operation-handler in schemas. For example:
    
    ```
    {
      "get": {
        "summary": "Get list",
        "x-eov-operation-id": "getList",
        "x-eov-operation-handler": "list.js",
        "responses": {
           ...
    ```
    mdmower-csnw committed Jun 2, 2024
    Configuration menu
    Copy the full SHA
    ee2841e View commit details
    Browse the repository at this point in the history
  2. Minor cleanup

    - Restore original "baseName" variable name
    - Make sure string path handling is exactly the same as prior to URL
      handling was added
    mdmower-csnw committed Jun 2, 2024
    Configuration menu
    Copy the full SHA
    a3eb7df View commit details
    Browse the repository at this point in the history