<!-- Kamailio Pull Request Template -->
#### Pre-Submission Checklist <!-- Go over all points below, and after creating the PR, tick all the checkboxes that apply --> <!-- All points should be verified, otherwise, read the CONTRIBUTING guidelines from above--> <!-- If you're unsure about any of these, don't hesitate to ask on sr-dev mailing list --> - [X] Commit message has the format required by CONTRIBUTING guide - [X] Commits are split per component (core, individual modules, libs, utils, ...) - [X] Each component has a single commit (if not, squash them into one commit) - [X] No commits to README files for modules (changes must be done to docbook files in `doc/` subfolder, the README file is autogenerated)
#### Type Of Change - [ ] Small bug fix (non-breaking change which fixes an issue) - [X] New feature (non-breaking change which adds new functionality) - [ ] Breaking change (fix or feature that would change existing functionality)
#### Checklist: <!-- Go over all points below, and after creating the PR, tick the checkboxes that apply --> - [X] PR should be backported to stable branches - [X] Tested changes locally - [X] Related to issue #3037
#### Description I can not remember the last time I wrote any C which was likely a class assignment last century. Anyways I came across this issue and it seemed in reach to get the ball rolling. I know this PR needs more work but my goal is to share my progress to help move this feature forward.
Based on https://github.com/svaarala/duktape/tree/master/extras/module-node added: - duk_module_node.h - duk_module_node.c
updated: - app_jsdt_api.h - app_jsdt_api.c
Included the extra header and initialize the bindings after 'load JS context' was created.
added `cb_resolve_module` to resolve the full file system path for requested_id and parent_id added `cb_load_module` function which uses `jsdt_load_file` to load resolved file
With absolute and relative modules working I met my current requirements to allow breaking routing into multiple smaller files.
You can view, comment on, or merge this pull request online at:
https://github.com/kamailio/kamailio/pull/3038
-- Commit Summary --
* app_jsdt: add duk_module_node for JS module resolution
-- File Changes --
M src/modules/app_jsdt/app_jsdt_api.c (65) M src/modules/app_jsdt/app_jsdt_api.h (3) A src/modules/app_jsdt/duk_module_node.c (333) A src/modules/app_jsdt/duk_module_node.h (17)
-- Patch Links --
https://github.com/kamailio/kamailio/pull/3038.patch https://github.com/kamailio/kamailio/pull/3038.diff