From d732db7dd2900a4b1721187b6c2c8329c0cc76a0 Mon Sep 17 00:00:00 2001 From: Slavo Vojacek Date: Mon, 14 Mar 2022 18:53:41 +0000 Subject: [PATCH] fix: remove location --- lambda-functions/ports/lambda.ts | 9 +++------ lambda-functions/secrets/secrets.ts | 8 ++------ 2 files changed, 5 insertions(+), 12 deletions(-) diff --git a/lambda-functions/ports/lambda.ts b/lambda-functions/ports/lambda.ts index 351a55e..e2b2048 100644 --- a/lambda-functions/ports/lambda.ts +++ b/lambda-functions/ports/lambda.ts @@ -10,15 +10,12 @@ export class Lambda { } createSecretHandler = apiGateway.middify<{ encryptedBytes: string; expiresIn: number }>( - async ({ body, requestContext }) => { - // TODO: Remove after testing - console.log(JSON.stringify(requestContext, null, 2)); - + async ({ body }) => { try { - const { id, expiresAt, location, viewUrl } = await this.secrets.create(body); + const { id, expiresAt, viewUrl } = await this.secrets.create(body); const jsonResponse = { id, expiresAt }; - const headers = { Location: location.toString(), 'X-View-Url': viewUrl.toString() }; + const headers = { 'X-View-Url': viewUrl.toString() }; return apiGateway.formatJSONResponse(jsonResponse, 201, headers); } catch (error) { diff --git a/lambda-functions/secrets/secrets.ts b/lambda-functions/secrets/secrets.ts index b2bc922..83b060f 100644 --- a/lambda-functions/secrets/secrets.ts +++ b/lambda-functions/secrets/secrets.ts @@ -6,7 +6,7 @@ import { SecretNotFoundError } from './error'; import { Secret } from './secret'; type CreateSecretInput = { encryptedBytes: string; expiresIn: number }; -type CreateSecretResult = { id: string; expiresAt: number; location: URL; viewUrl: URL }; +type CreateSecretResult = { id: string; expiresAt: number; viewUrl: URL }; type BurnSecretInput = { id: string }; type BurnSecretResult = { encryptedBytes: string }; @@ -40,15 +40,11 @@ export class Secrets implements SecretsImpl { const { id, expiresAt } = await this.ddbRepo.createSecret(secret); - // TODO: Fix - const location = new URL('https://test'); - location.pathname = `/secrets/${id}`; - const viewUrl = new URL(this.webViewUrl.toString()); viewUrl.searchParams.append('id', id); viewUrl.searchParams.append('region', this.region); - return { id, expiresAt, location, viewUrl }; + return { id, expiresAt, viewUrl }; }; burn = async ({ id }: BurnSecretInput): Promise => {