Preheat oven to 350°F (175°C) and line a 12-cup muffin tin with cupcake liners.
In a bowl, whisk together flour, cocoa, baking powder, baking soda, and salt.
In another bowl, beat eggs and sugar until fluffy. Add milk, oil, espresso powder, and peppermint extract; mix until combined.
Gradually add dry ingredients and mix until smooth.
Divide batter evenly into cupcake liners and bake for 18 minutes or until a toothpick comes out clean.
Cool completely before frosting.
To make frosting: beat butter until creamy, then add powdered sugar, cocoa, espresso, and peppermint extract. Adjust texture with heavy cream.
Frost cupcakes and garnish with crushed candy canes or chocolate shavings.