Skip to content

Commit

Permalink
Add JWT Authentication
Browse files Browse the repository at this point in the history
  • Loading branch information
leungkinghin-ct committed Feb 7, 2024
1 parent 2d586c2 commit b8649c3
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion processor/src/routes/payment-components.route.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
import { FastifyInstance, FastifyPluginOptions } from 'fastify';

import { PaymentService } from '../services/types/payment.type';
import { SupportedPaymentComponentsSchema } from '../dtos/payment-methods.dto';
import { JWTAuthenticationHook } from '@commercetools/connect-payments-sdk';

type PaymentComponentsRoutesOptions = {
paymentService: PaymentService;
jwtAuthHook: JWTAuthenticationHook;
};

export const paymentComponentsRoute = async (
Expand All @@ -12,7 +15,14 @@ export const paymentComponentsRoute = async (
) => {
fastify.get(
'/payment-components',

{
preHandler: [options.jwtAuthHook.authenticate()],
schema: {
response: {
200: SupportedPaymentComponentsSchema,
},
},
},
async (request, reply) => {
const result = await options.paymentService.getSupportedPaymentComponents();
reply.code(200).send(result);
Expand Down

0 comments on commit b8649c3

Please sign in to comment.