Skip to content

Organize folder structure for generated typescript handlers #855

Answered by cogwirrel
fahadnasir40 asked this question in Q&A
Discussion options

You must be logged in to vote

Hey Fahad!

I'm afraid the @handler trait in the Smithy model will always generate the handlers in the root of the src folder.

To achieve your custom directory setup you have to do a little bit of customisation - what I'd recommend is something like:

  1. Add the @handler trait as normal when you add an operation
  2. pdk build to generate the new handler and test, as well as the CDK lambda function construct
  3. Remove the @handler trait from the operation
  4. Move the handler/test to your desired folder
  5. Copy/paste the CDK construct for the lambda from packages/api/generated/infrastructure/typescript/src/functions.ts into your infrastructure package. Make sure you update the asset path to point to your pa…

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@fahadnasir40
Comment options

@cogwirrel
Comment options

Answer selected by fahadnasir40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants