DEV Community

Discussion on: Designing a better architecture for a Node.js API

Collapse
 
pacheco profile image
Thiago Pacheco

Hi Mridul, thanks for the feedback!
For the question one, yes the main idea was to have the business logic in the service layer.
For the second question I totally agree that it would be great to separate the database queries into a repository. I didn’t separate it like that in this tutorial for simplicity purposes.
I have created recently another structure that might accommodate these changes and some other features. For this new one I am using typescript and I also have the tests setup.
I am thinking about creating a series of articles about it, do you think it would be a helpful?
Thanks again!

Collapse
 
mridul1024 profile image
Mridul Sharma

Yes, It would definitely help me and other beginners like me. I was also looking for some good articles on unit testing and integration testing. Will it be possible for you to incorporate that in your articles?

Collapse
 
dadobaag profile image
DaDoBaag

Yes please make an article and/or repository about this architecture with TypeScript. I'm struggling to create a strictly typed backend with Express + Mongoose.

Thread Thread
 
pacheco profile image
Thiago Pacheco

I'll try to work on a tutorial about it this weekend. I can send you a repo earlier if you'd like to play around with the idea.

Thread Thread
 
dadobaag profile image
DaDoBaag

Awesome, I'd love to get a link to the repo!