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

[FEATURE] Add custom folder path option for Smithy-generated handlers #860

Open
1 of 2 tasks
fahadnasir40 opened this issue Oct 17, 2024 · 3 comments
Open
1 of 2 tasks
Labels
feature-request New feature or request needs-triage

Comments

@fahadnasir40
Copy link

Describe the feature

Add an option in the Smithy handler trait to define a custom folder path for the generated handers.

Use Case

Current settings generate all handlers inside the src and test folders with a flat hierarchy. Need an option to customize the individual handler path.

Proposed Solution

Add a new optional subdir option to the Smithy handler trait?

Other Information

We may also need to add this option for async handlers.

Acknowledgements

  • I may be able to implement this feature request
  • This feature might incur a breaking change

PDK version used

0.23.66

What languages will this feature affect?

Typescript, Java, Python

Environment details (OS name and version, etc.)

Linux, Windows etc

@fahadnasir40 fahadnasir40 added feature-request New feature or request needs-triage labels Oct 17, 2024
@cogwirrel
Copy link
Member

I think the tricky part for typescript will be getting the esbuild command right to bundle all the handlers - I wonder if we'd need to make it more generic so it finds all ts files in the target directory which export a function called handler? :) Not sure exactly the best way to achieve this though - could maybe add a new script to run.ts but it might increase the size of the bundled run.js that ends up in the PDK distributable as that itself would then include esbuild!

@fahadnasir40
Copy link
Author

I think we may need an index file to store the paths of the generated handlers. Is it possible to read handler data from the model/.api.json file? I'm not quite sure how these projects are linked together. If we choose to scan all files in src/**/* directory, we can run a command with a regex and pass the result to the current esbuild command.

@cogwirrel
Copy link
Member

We can read the model/.api.json at build time (just not at project synthesis time as users should be able to add an operation and just rebuild rather than having to re-synthesize too).

So yes I think we could have a script/command read model/.api.json to find where all the handlers are and pass that to the esbuild command :) Ideally I think we'll want this as a node.js script which we can then pass the output to esbuild, so it's as platform agnostic as possible :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature-request New feature or request needs-triage
Projects
None yet
Development

No branches or pull requests

2 participants