1

I'm writing a nodejs client for an API. In my client's code, I would like to use concepts that represent the domain of the API (Products, Lists, Categories) etc. My question is what is the best way to achieve this and instantiate these classes. Is there a pattern I can use? thanks.

dbr
  • 17
  • 6
  • 1
    This is a very broad question that is hard for anyone to answer without a ton more details. Broad design-advice or architecture-advice questions do not work well here and are generally considered off-topic. When you haven't even described any details of what the API is trying to achieve, it's even harder. There are hundreds of articles written about API design. I'd suggest you read a bunch of those and come back here when you have a much more specific question about some of them. – jfriend00 Oct 28 '22 at 05:14
  • Also note that API design and domain design are quite different aspects of software development. – ArwynFr Oct 28 '22 at 09:00

1 Answers1

0

I would like to use concepts that represent the domain of the API (Products, Lists, Categories)

Single Responsibility Principle of SOLID rules also can be appied to design API. It means that Products API should not contain methods for other entities like Animals.

My question is what is the best way to achieve this and instantiate these classes

In my view, you can start from layered architecture. Good answers about layered architecture can be seen here

In addition, you can see this post about Domain Drive Design in NodeJS

StepUp
  • 36,391
  • 15
  • 88
  • 148