From 9d857b0e4c5f131b9a41375a88b6e812b9500b12 Mon Sep 17 00:00:00 2001 From: Anbraten Date: Wed, 1 Feb 2023 11:22:23 +0100 Subject: [PATCH] fix: correct subscription get endpoint (#30) --- packages/server/Containerfile | 2 +- packages/server/src/api/endpoints/subscription.ts | 9 ++++++++- packages/server/src/api/index.ts | 2 +- 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/packages/server/Containerfile b/packages/server/Containerfile index 221f675..c3e73dd 100644 --- a/packages/server/Containerfile +++ b/packages/server/Containerfile @@ -6,7 +6,7 @@ RUN apk --no-cache add ca-certificates WORKDIR /app -CMD ["node", "index.js"] +CMD ["node", "--enable-source-maps", "index.js"] COPY ./packages/server/dist/ . diff --git a/packages/server/src/api/endpoints/subscription.ts b/packages/server/src/api/endpoints/subscription.ts index 412076f..822f187 100644 --- a/packages/server/src/api/endpoints/subscription.ts +++ b/packages/server/src/api/endpoints/subscription.ts @@ -250,7 +250,14 @@ export function subscriptionEndpoints(server: FastifyInstance): void { ? getActiveUntilDate(subscription.lastPayment, subscription.anchorDate) : undefined; - await reply.send({ ...subscription, activeUntil }); + const _subscription = { + ...subscription, + activeUntil, + changes: subscription.changes.getItems().map((change) => ({ ...change, subscription: undefined })), + invoices: subscription.invoices.getItems().map((invoice) => ({ ...invoice, subscription: undefined })), + }; + + await reply.send(_subscription); }, }); } diff --git a/packages/server/src/api/index.ts b/packages/server/src/api/index.ts index 00de1fa..dfa221d 100644 --- a/packages/server/src/api/index.ts +++ b/packages/server/src/api/index.ts @@ -114,7 +114,7 @@ export async function init(): Promise { description: 'Documentation for the Gringotts api', version: '0.1.0', }, - host: 'localhost:3000', + host: `localhost:${config.port}`, schemes: ['http', 'https'], consumes: ['application/json'], produces: ['application/json'],