2

I worked with standard Rest API Spring Boot applications 2 years. For my next project I need to use JsonApi.

I made little research and see few libraries:

https://github.com/katharsis-project/katharsis-framework

https://github.com/crnk-project/crnk-framework

https://github.com/yahoo/elide


My question is in standard Rest Api we have:

controllers -> services -> repositories

but in JsonApi we have:

resources (models, dtos) -> repositories

Where we can write custom logic if we don't have services.

In upper libraries here is resources which can only made CRUD operations with DB.

In JsonApi resources imitate controllers which have direct relation with repositories.

faroali
  • 21
  • 2
  • My question is where I can made custom logic in Json Api if is resources in direct relation with repositories. Is it possible to make middleware between resources and repositories before save. – faroali Nov 06 '20 at 21:58
  • Are you aware of the [How to JSON API tutorial for Spring using CRNK framework](https://howtojsonapi.com/spring.html)? Not much experience with CRNK framework. But from your question it seems as if you are mixing terms of JSON API specification with framework and library specific concepts. This makes it even harder for me to understand if you are asking about the architecture of CRNK framework or the JSON API specification itself. – jelhan Nov 09 '20 at 08:47

2 Answers2

2

Katharsis is a bunk project. Crnk is a fork from it.

Christian Bongiorno
  • 5,150
  • 3
  • 38
  • 76
0

There is 3 Method to implement custom logic (Elide 6) :

1- Use a Dao and Map your attributes to create an object or list of objects.

2- Work with computed attributes it helps alot specially if you need metrics that shouldn't be persisted in the database .

3- Create your own datastore that implements DataStore also you need a transaction datastore(you can create logic in loadObject method for exemple).