fix signin signout and apply the new style

This commit is contained in:
root
2026-05-24 23:58:54 -04:00
parent bf97a072dd
commit 9bd0938951
68 changed files with 851 additions and 200 deletions
@@ -9,21 +9,23 @@ import * as paypal from '../../services/paypalService'
import * as service from './subscription.service'
import { checkoutSchema, changePlanSchema, capturePaypalSchema } from './subscription.schemas'
const publicRouter = Router()
const webhookRouter = Router()
const router = Router()
// ─── Public ────────────────────────────────────────────────────
router.get('/plans', (_req, res) => {
publicRouter.get('/plans', (_req, res) => {
ok(res, service.getPlans())
})
router.get('/providers', (_req, res) => {
publicRouter.get('/providers', (_req, res) => {
ok(res, service.getProviders())
})
// ─── Webhooks (no auth) ────────────────────────────────────────
router.post('/webhooks/amanpay', async (req, res, next) => {
webhookRouter.post('/webhooks/amanpay', async (req, res, next) => {
try {
const rawBody = JSON.stringify(req.body)
const signature = (req.headers['x-amanpay-signature'] as string) ?? ''
@@ -35,7 +37,7 @@ router.post('/webhooks/amanpay', async (req, res, next) => {
} catch (err) { next(err) }
})
router.post('/webhooks/paypal', async (req, res, next) => {
webhookRouter.post('/webhooks/paypal', async (req, res, next) => {
try {
const rawBody = JSON.stringify(req.body)
const isValid = await paypal.verifyWebhookEvent(req.headers as Record<string, string>, rawBody)
@@ -97,3 +99,4 @@ router.post('/resume', requireRole('OWNER'), async (req, res, next) => {
})
export default router
export { publicRouter as subscriptionPublicRouter, webhookRouter as subscriptionWebhookRouter }