| 1 | import { Router } from "express"; |
| 2 | import { SubscriptionController } from "../controllers/subscription.controller"; |
| 3 | import { authenticate } from "../middleware/auth.middleware"; |
| 4 | |
| 5 | const router = Router(); |
| 6 | |
| 7 | // Public routes - webhook needs raw body for Stripe signature verification |
| 8 | router.post("/webhook", SubscriptionController.handleWebhook); |
| 9 | |
| 10 | // Protected routes |
| 11 | router.get("/plans", SubscriptionController.getPlans); |
| 12 | router.get("/user", authenticate, SubscriptionController.getUserSubscription); |
| 13 | router.post( |
| 14 | "/checkout", |
| 15 | authenticate, |
| 16 | SubscriptionController.createCheckoutSession |
| 17 | ); |
| 18 | router.post("/cancel", authenticate, SubscriptionController.cancelSubscription); |
| 19 | |
| 20 | export default router; |