Created a new Generator constructor function to help with the generation of the hypermedia responses. It's built with the Builder Pattern in mind. It allows you to set the necessary data for generation at a particular granularity in the API specification, and maintain state of where the generation is currently. It accepts Resources, Resource, Method, status codes, Affordances, and a Delegate callback Function as fields using accessor methods. You proceed with an invocation of the generate method to start the generation. This allowed me the ability to completely remove Resources.generate, Resource.generate, and Method.generate which were getting to be almost unmanageable. I was able to decouple all module-scoped references from the generation code by using the delegate callback interface. The delegate handles creating the XHN Affordances collection, asking the user on the CLI to select an Affordance, setting the selected Affordances in the collection, serializing the collection, creating and saving the respective paths, and proceeding to the next scenario with a Generator.generate invocation. The reference to the Generator instance is now module-scoped so I can use the same instance anywhere the generation would be started. I also check if the serialization for the hypermedia responses should be JSON or XML within the Commander gen callback function. Last, but not least, I create the api path at the root of the module if it doesn't exist.
Created a new Generator constructor function to help with the generation of the hypermedia responses. It's built with the Builder Pattern in mind. It allows you to set the necessary data for generation at a particular granularity in the API specification, and maintain state of where the generation is currently. It accepts Resources, Resource, Method, status codes, Affordances, and a Delegate callback Function as fields using accessor methods. You proceed with an invocation of the generate method to start the generation. This allowed me the ability to completely remove Resources.generate, Resource.generate, and Method.generate which were getting to be almost unmanageable. I was able to decouple all module-scoped references from the generation code by using the delegate callback interface. The delegate handles creating the XHN Affordances collection, asking the user on the CLI to select an Affordance, setting the selected Affordances in the collection, serializing the collection, creating and saving the respective paths, and proceeding to the next scenario with a Generator.generate invocation. The reference to the Generator instance is now module-scoped so I can use the same instance anywhere the generation would be started. I also check if the serialization for the hypermedia responses should be JSON or XML within the Commander gen callback function. Last, but not least, I create the api path at the root of the module if it doesn't exist.

coastjs/coast