C
C#4d ago
Cyclomatic

c# API + angular front end

Hi, This is more of a design question... I have a web api written in C# and a front end writtein in angular. The web api has a settings file associated with it. The web api and front end are both served by kestrel (same port). The front end has some settings as well (in the assets folder). One setting, for example, for the front end is a theme. The theme can be changed using the front end, where it makes a request to the API to set the theme setting. My question - I could have the theme setting live in the assets of the angular app, or I could have the setting live in a settings file in the API bin directory and when the frontend is loaded it makes a call to the API to get the settings and applies them. Which is the more common/better approach for storing this setting? I feel like it's better for it to live in the assets folder of the angular app, but more maintainable when it is in a settings file of the API. Thoughts? (hope my question makes sense!)
3 Replies
daye
daye4d ago
Hey, what's the scope of the theme settings? Is it something as simple as light theme/dark theme/accent colour settings? If so, I'd probably opt for something simple as saving the user's preference on the client in localstorage.
Cyclomatic
CyclomaticOP4d ago
i only use theme as an example, but actually consider it an administrative setting so that not any user can change the setting but it should apply to all users
daye
daye4d ago
In that case I assume you have some type of overarching database entity? Like an organisation for example, and then users part of that organisation inherit the settings? Assuming that's the case, maybe saving the settings on the organisation record in your database would be something you're after. Either individual setting properties or a json containing the settings

Did you find this page helpful?