Streamlining Front-End Development with TypeScript Generator
Problem
In most web-based systems, the client-side code and server-side code need to mirror each other, requiring models and HTTP requests on the client side to reflect the server-side endpoints. Typically, due to the separation of client and server development, this process involves redundant efforts and increases the likelihood of errors. Maintaining synchronization between both sides is cumbersome, leading to higher development and maintenance costs.
Solution
We developed a TypeScript Generator to tackle this problem. This tool automatically generates client-side models and HTTP requests based on the server-side code, ensuring consistency and reducing development time. Here’s how it works:
- Automatic Generation: Once a model and endpoint are established on the server, our library creates the corresponding front-end code. Any subsequent changes in the backend are reflected in the frontend through automatic updates.
- TypeScript Capabilities: The generated models retain all TypeScript capabilities, including type information and field optionality.
- Service Integration: The tool produces services that communicate with every server API endpoint, simplifying front-end integration.
- Configurable Code: Developers can configure type serialization and mapping, ensuring compatibility between front-end and back-end libraries.
Benefits
- Reduced Front-End Code: Decreases the volume of frontend code by approximately 15%, saving development time and reducing errors.
- Consistent Models: Ensures consistency between client and server models, reducing debugging and testing time.
- Enhanced Efficiency: Simplifies the integration process, allowing developers to focus on core functionality rather than boilerplate code.
Features
- TypeScript Interfaces: Generated based on Java models.
- TypeScript Services: Created for Java REST controllers.
- Annotation Support: Supports Jackson annotations.
- Spring MVC Compatibility: Works seamlessly with Spring MVC.
- Custom Type Mapping: Allows for custom type conversions.
- Modular Strategy: Supports package per module strategy.
- Import Generation: Automatically generates necessary imports.
- Framework Support: Compatible with Angular and React.
The TypeScript Generator has been successfully utilized in numerous projects, demonstrating significant reductions in code volume and development time.
JSON Scopes
Enhancing Application Efficiency with JSON Scopes Library
Problem
Application entities often have bidirectional associations, leading to cyclic dependencies that are problematic for JSON serialization. Typically, developers use Data Transfer Objects (DTOs) to address this issue. However, maintaining a separate DTO model for each business model is labor-intensive and increases development, testing, and support times due to the proliferation of DTOs.
Solution
Our JSON Scopes library offers a more efficient approach by allowing developers to configure data serialization directly with Jackson annotations, eliminating the need for DTOs. Here’s how it works:
- Custom Serialization: Define exactly what data should be serialized in controllers, ensuring only the necessary data is included.
- Cyclic Dependency Handling: The serializer processes cyclic dependencies by serializing an object once and placing proxies elsewhere. During deserialization on the client side, proxies are replaced with references to the original objects, maintaining a graph structure.
- Reduced Payload Size: By transferring data in a tree format, the library reduces the overall size of the model and request payloads.
Benefits
- Eliminates DTOs: Removes the need for maintaining separate DTO models, simplifying the codebase.
- Reduces Code Duplication: Minimizes redundant code on both the backend and frontend.
- Optimizes Data Transfer: Decreases the size of request payloads, improving application performance.
- Simplifies Maintenance: Reduces development and maintenance efforts by consolidating entity and data serialization logic.
Features
- GraphQL-Like Functionality: Conceptually similar to GraphQL, providing flexible data retrieval.
- Entity Serialization: Directly serializes entities without needing DTOs.
- Compatibility: Works seamlessly with Hibernate and Spring frameworks.
- Proven Solution: Successfully implemented in multiple projects, demonstrating its value and effectiveness.
By using the JSON Scopes library, developers can streamline application models, reduce payload sizes, and enhance overall efficiency, making it a powerful tool for modern web development.