From b8649c39c15424f475a0cdb34cfd0b90654665f5 Mon Sep 17 00:00:00 2001 From: King-Hin Leung Date: Wed, 7 Feb 2024 15:41:56 +0100 Subject: [PATCH] Add JWT Authentication --- processor/src/routes/payment-components.route.ts | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/processor/src/routes/payment-components.route.ts b/processor/src/routes/payment-components.route.ts index 0512810..2dbc639 100644 --- a/processor/src/routes/payment-components.route.ts +++ b/processor/src/routes/payment-components.route.ts @@ -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 ( @@ -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);