Most people are focusing on career advice, but it sounds like you’re also looking for some psychological reassurance. In that case, the best advice I can give is to avoid letting this affect your view of yourself. It’s easy to forget that we are more than our careers or our jobs. How will you feel about this firing 50 years from now?
This is also why it’s inportant to have a balanced lifestyle. If the only focus of your life is your career, then getting fired is devastating. But if you have other things in your life — hobbies, friends, a relationship — you have those to fall back to when something goes wrong with work.