docs icon indicating copy to clipboard operation
docs copied to clipboard

Best practices around exporting/import backend

Open kekami opened this issue 9 months ago • 2 comments

I'm building a project and the number of custom resources are growing. Most/all examples show custom resources added to backend.ts, and I wonder what the best approach would be if I were to extract resources into separate files. My question is mainly on how backend should be handled.

E.g. if I have a custom RestAPI construct, should I be doing this

new RestAPI(restApiStack, 'rest-api', {
  functions: {
    createCustomer: backend.createCustomerHandler.resources.lambda,
    createEmployee: backend.createEmployeeHandler.resources.lambda,
  },
});

vs

just importing backend from within the RestApi construct? Not sure if exporting backend would result in circular dependencies from a CDK perspective.

kekami avatar May 16 '24 18:05 kekami