Adrián Mouly
09/09/2021, 9:41 AMindex.ts
file?
Currently I have 14 stacks referenced from index, and expecting to double that amount in the next month.
My index contains not also the stacks but also the addDependency
for each of them.
So currently it’s a mess.
I been thinking to create function
s for each of the “Features” that I have, which is basically a grouping of stacks… but to do that I have to create types for each Stack, due most of them has readonly
attributes which are exposed to other stacks.
Maybe I can create TS classes? and create input
and output
types? Input will be construct dependencies and output will be anything that has to be shared.Adrián Mouly
09/09/2021, 10:14 AMAdrián Mouly
09/09/2021, 10:14 AMthdxr
09/09/2021, 12:46 PMAdrián Mouly
09/09/2021, 12:57 PMreadonly
attributes. But I can use the actual class type too, and worked.thdxr
09/09/2021, 2:06 PMconst mystack = new MyStack() // stores all exported properties in a field called outputs
const nextstack = new NextStack({ mystack: mystack.outputs })
// Prop types for NextStack
type Props = {
mystack: typeof MyStack["outputs"]
}
Adrián Mouly
09/09/2021, 2:08 PMAdrián Mouly
09/09/2021, 2:08 PMAdrián Mouly
09/09/2021, 2:08 PMAdrián Mouly
09/09/2021, 2:09 PMthdxr
09/09/2021, 2:09 PMAdrián Mouly
09/09/2021, 2:09 PMthdxr
09/09/2021, 2:12 PMconst groupA = GroupA(app)
function GroupA(app) {
const stackA = new StackA(app, ...)
const stackB = new StackB(app, ...)
return { stackA: stackA.outputs, stackB: stackB.outputs }
}
// can use ReturnType<typeof GroupA> to get the type of that group if you want to pass it into something else
Adrián Mouly
09/09/2021, 2:12 PMAdrián Mouly
09/09/2021, 2:13 PMAdrián Mouly
09/09/2021, 2:13 PMconst network = new Network(app);
const yabble = new Yabble(app, {
networkStack: network.networkStack,
});
new Marketing(app, {
yabbleApiStack: yabble.yabbleApiStack,
yabblePlatformStack: yabble.yabblePlatformStack,
});
new HeyYabble(app, {
networkStack: network.networkStack,
yabbleApiStack: yabble.yabbleApiStack,
yabblePlatformStack: yabble.yabblePlatformStack,
openAiApiStack: yabble.openAiApiStack,
iamAuthStack: yabble.iamAuthStack,
});
Adrián Mouly
09/09/2021, 2:14 PMAdrián Mouly
09/09/2021, 2:14 PMthdxr
09/09/2021, 2:18 PMAdrián Mouly
09/09/2021, 2:19 PMthdxr
09/09/2021, 2:25 PMAdrián Mouly
09/09/2021, 2:25 PMAdrián Mouly
09/09/2021, 2:26 PM*Stacks
.Adrián Mouly
09/09/2021, 2:26 PMYabbleStacks
… but could be confusing.