feat: Verify paddle webhooks

This commit is contained in:
Faruk AYDIN
2023-03-21 22:02:11 +03:00
parent 4202f963c3
commit e1d26325f3
9 changed files with 201 additions and 8 deletions

View File

@@ -1,10 +1,12 @@
import { Router } from 'express';
import graphQLInstance from '../helpers/graphql-instance';
import webhooksRouter from './webhooks';
import paddleRouter from './paddle.ee';
const router = Router();
router.use('/graphql', graphQLInstance);
router.use('/webhooks', webhooksRouter);
router.use('/paddle', paddleRouter);
export default router;

View File

@@ -0,0 +1,19 @@
import { Response, Router, NextFunction, RequestHandler } from 'express';
import { IRequest } from '@automatisch/types';
import webhooksHandler from '../controllers/paddle/webhooks.ee';
const router = Router();
const exposeError =
(handler: RequestHandler) =>
async (req: IRequest, res: Response, next: NextFunction) => {
try {
await handler(req, res, next);
} catch (err) {
next(err);
}
};
router.post('/webhooks', exposeError(webhooksHandler));
export default router;