I've been working on a TypeScript project and am looking to improve the structure of some elements we're using. There is a file that's currently defined as a class, but I think it could be simplified down to a basic dictionary/POJO. Here's how it's currently set up:
export class AppSettings{
public static get API(): string { return '/apis';}
public static get API_COMMON(): string {return `${this.API}/common`;}
public static get API_COMMON_VENDORS(): string {return `${this.API_COMMON}/vendors`;}
//...redacted for brevity...
//... return `${PREVIOUS_API_GET}/nextURL`....
}
The desired end result is to access the values through indexing on the object. (e.g.
AppSettings['domain']['endpoint']
)
In essence, our app has different "areas" or "domains" that perform similar functions but cater to varying use cases. For instance, we have an admin portal and a client-facing app, both dealing with the same types of data (invoices, batches, purchase orders, etc.). So, just to clarify, a practical example would look like
AppSettings['admin']['getBatches']
or AppSettings['customer']['getBatches']
So, my question is: How can I go about refactoring this setup?