How to add new API?

Viewed 160

Sorry for my English. I am interested in adding some new APIs and would appreciate guidance on how to achieve that. I remember previous documentation contained instructions on developing new APIs, however, it seems that the current ones do not.

2 Answers

Dependencies between packages

For most api, the flow chart is very simple as follows.

router -> middleware -> controller(use schema) -> service -> repo(use entity)

If you want to develop a new API, you can follow the steps below.

  1. Adding a routing rule (GET/POST/PUT...) in router.
  2. Adding a controller for handler requests. the request should be validated in the controller.
  3. Adding a service to process business.
  4. Adding a repo for saving or querying data from the database or cache.
  5. Regenerate swagger documentation and test API.

I'll add this original section to the documentation. You can also continue to ask us if you have any questions during the development process. :)