Migrate from REST to gRPC

[Under construction]

  • Backend differences

    • REST :

      • djangorestframework

        • Implementation of

        book.apis.py

        book.serializers.py

      • Middleware cors : bypass the cross site origin.

      • Handle snake-case and camel-case inconsistency.

    • grpc :

      • djangorestframework + djangogrpcframework + grpcio + grpcio-tools

      • Implementation of

        book.schema.py

  • Frontend differences The difference is only the database query service.

    • REST : Use URL end point. category.js

        const CategoryService = {
            list: () => {
                let url = "api/category/";
                return Request.get(url);
            }
        }

      request.js

        const Request = {
      
            get: async (url) => {
      
                try {
                    let result = await axios.get(
                        getFullURL(url),
                        getHeaderConfig()
                    );
                    return Promise.resolve(result.data);
                } catch (error) {
                    console.log(error);
                    return Promise.reject("get error");
                }
      
            }
        }
    • grpc : Always use POST method to submit query. category.js

        const CategoryService = {
      
        }

      request.js

      ```javascript const Request = {

        get: async (query) => {
      }
  }
```

Last updated