0

I am trying to apply DDD to a Vue project (so it's DDD on the frontend) and I have a doubt as to where store a props type. A Vue component can have props, which is basically named data passed to the component. Most of my components that work as a page are stored inside the application folder, because they manage all the data flux, that is, the repositories that make API calls, instanciating domain classes, etc. For each of these application components, I have a .ts file that speciafies its props; so together with my Profile.vue, I have a ProfileProps.ts.

Profile.vue: the props being defined

import type { ProfileProps } from './ProfileProps'

const props = defineProps<ProfileProps>()

The props type inside ProfileProps.ts

export type ProfileProps = {
  user: IBackendUser
}

As you can see, there's only one prop and it's also typed as what I expect the backend to pass to my component: the user. My question is, where should I keep this interface of mine IBackendUser: maybe a folder in the application called interfaces, or maybe put it in the domain folder?

PS.: I have a separate file for the props because some components have extense props (big objects), and I want to keep the pattern for all the project.

1 Answer 1

1

Some options:

  • Domain Layer: If IBackendUser is a core domain concept, put it in the domain folder.

  • Application Layer: If it's specific to the application logic, place it in an interfaces subfolder within the application folder.

  • Component-Specific: If it's only used in the Profile component, you could keep it in the same folder as Profile.

  • Shared Types: If used across layers, consider a shared or common folder.

Choose based on where the type is most relevant and keep your approach consistent across the project.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.