Currently, I am utilizing WebStorm as my IDE to work on a personal project that I envision turning into a game in the future. The primary goal of this project is to create an Alpha version that I can showcase to potential employers, as I am actively seeking employment and view this project as a valuable addition to my resume. In this developmental phase, I am implementing the Builder design pattern to construct intricate objects within the project. Some of these objects are distributed across multiple services, a decision made based on logical organization. The game itself is intended to be a text-based RPG where players can craft characters, explore various locations, collect items, and more. However, I have encountered challenges due to the necessity of using multiple services with Builder objects, resulting in circular dependency errors when attempting to combine them all into a "super object."
In an attempt to resolve this issue, I explored integrating NestJS into the project, as Nest offers a solution for Circular Dependency errors. Despite following the guidelines provided by Nest's documentation, the error persists.
To further illustrate the situation, the project successfully builds a localhost environment; however, it lacks functionality.
You may refer to the Terminal Error Image linked above to visualize the error more clearly.
Highlighted below are excerpts from two Service files. According to Nest's recommendations, both Service files should employ ForwardRef - a step which I seem to have overlooked. Additionally, I've installed essential packages including @nestjs/common and @nestjs/core. Notably, while testing other Builder objects that do not rely on external services, the console displays expected results without any issues. Hence, I am inclined to believe that the root cause lies within these Circular Dependencies.
decisions.service.ts
(Contents of Decisions Service file)
The aforementioned Decision Service interplays only with one preceding service, leveraging its output as values for currentPage
and nextPage
.
chapter-one.service.ts
(Contents of Chapter One Service file)
While some aspects of the code might be peripheral to the main issue, it's worth noting the consistent use of ForwardRef in this particular file and others associated with chapter-one.service.ts
.
Feel free to click on the link to the error image provided above for a detailed look at the error code. Any guidance or suggestions to tackle the circular error problem or restructure the code for optimal results would be highly appreciated.