Cydo
Explore posts from servers✅ How can I take 2 existing repos (client and backend) and combine them?
I've always made my frontend and backends separate repos, and would like to instead make set it up where the frontend and client are both in the same repo. But it doesnt seem as simple as just creating a parent folder with 2 subfolders one for frontend and one for backend and then or am I wrong? I assumed you'd have one .gitignore in the root instead of a .gitignore in each subfolder? Or because how .net has solutions is it more complex?
39 replies
✅ When should you or shouldnt you return nested data in an api call?
Let's say I have a these tables in my database, Project, Members, Task, Comments and I want to return paginated data so a user can view all their projects, then view the tasks and members associated with the project and the comments associated with the individual tasks. Would you do this as all separate queries or do one query that returns all the data nested and paginated?
Here's my current thought process.
13 replies
✅ Having trouble handling errors when registering a new user
So my application is a .NET web api with a React front end, and im trying to handle all my errors on the backend during the register process and I dont seem to understand how errors are handled. When a user signs up im trying to account for all possible issues they could run into. For example wrong password length, missing special characters, uppercase, etc and then the same for email for example is it a valid email, is there any mistakes in the email for instance
test@test,com
as opposed to [email protected]
I noticed that modelstate is always valid with email part, but for password things seem to work.
the error that gets thrown when the email is not in a correct format actually comes from here var result = await _userManager.CreateAsync(user, registerRequestDTO.Password);
and it throws this error "Username 'test1@test,com' is invalid, can only contain letters or digits."
and I can't seem to figure out how to make it handle this error correctly so that it is in the format below, I don't think I can just hard code it because what if a different error is thrown, i want it to always come back in the format, Key: ['array of errors', '...' ]
like below.
But I'm not sure how to achieve that. This is what I set up for my code currently and that specific error always hits the ApplicationException
I'll attach the code in a gist since there is so much of it https://gist.github.com/CydoEntis/2d9160d6867651f8209214334779a3fe6 replies
✅ Unit of Work for just Repositories or Services as well?
When you create a unit of work and you add repositories inside of it so you aren't constantly newing up additional ones across your applications, should services also be added to the same unit of work? Another unit of work or not at all?
I don't see the harm in adding services to the unit of work so would that be a valid thing to do or will that cause issues somehow?
1 replies
✅ How to hide sensitive data, like database credentials api keys etc
I know you enter this stuff in your appsettings.json, but from what I can see your apisettings.json gets stored in your gitrepo, so is there something like a .env file in the .NET ecosystem where i can store everything in there omit it from git and then load that data into appsettings.json?
Everything I found so far is talking about setting the variables in an azure key vault or setting them inside of the terminal, am I missing something here? I'm just developing locally atm but even if i deploy this app, i dont think I will be using azure because of how expensive it is and would like to not use the key vault because of that, but at the same time i dont want any of this to be on my git repo for random ppl to potentially see as well.
16 replies