Youch! Those 2 things are mega events, which are somewhat random to go off. There is the option to turn them off when starting a new game, but for your game that's in play already...you will have to tough them out.
Mega Events were made to shake up te game drastically...as you see.
Take some time from attempting to fight them and research bigger hulls, better weapons and better defenses. Make sure your weapons/defenses compliment their weapons/defenses. If they got missiles and point defense, go at them with something other than missiles and get yourself some point defense.
Don't attempt to get starbases bakc up and running again until the near-by area is clear. Probably 2 sectors from the nearest pirate/peacekeeper may be enough to keep them from wandering over and pounding it.
BTW starbase weapons and defenses aren't a challenge to these ships nor mid-end game ships that you can make. It's just something that doesn't scale that well.