http-server icon indicating copy to clipboard operation
http-server copied to clipboard

Allow reading a javascript file for configuration defaults

Open wayfarer3130 opened this issue 3 years ago • 1 comments

What's the problem this feature will solve?

The issue is that I'd like to add a custom mapping for mime types based on things OTHER than the extension. To do that, I want to add an extra 'before' action. I can modify the codebase to do that, but I'd like to just allow custom renaming/header adds etc by including a JavaScrript file as part of the configuration. Once there is ANY configuration there, it might as well allow setting any configuration value.

Describe the solution you'd like

Include a module specified on the URL, or by default ./http-server-config.js if present. Use that module as a set of defaults.

This would allow fixing the mime types for two of my projects Static-Wado and dicomp10-to-dicomweb where the URL paths ending in any of /studies, /series, ,/instances and /metadata would be served as application/json. These are standard/published paths, so I can't just name the file ".json"

Alternative Solutions

Write a full custom bin/http-server that sets things specifically as desired. However, this means I need to deploy that and can't simply reference http-server as the suggested solution.

Note that nconf is NOT an alternative solution because it only allows JSON files to be used and not JavaScript files.

I have a pull request for this already.

wayfarer3130 avatar Dec 02 '21 19:12 wayfarer3130

This issue has been inactive for 180 days

github-actions[bot] avatar Jun 01 '22 12:06 github-actions[bot]