Skip to content

Commit

Permalink
fix: remove location
Browse files Browse the repository at this point in the history
  • Loading branch information
Slavo Vojacek committed Mar 14, 2022
1 parent ad19b73 commit d732db7
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 12 deletions.
9 changes: 3 additions & 6 deletions lambda-functions/ports/lambda.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
8 changes: 2 additions & 6 deletions lambda-functions/secrets/secrets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 };
Expand Down Expand Up @@ -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<BurnSecretResult> => {
Expand Down

0 comments on commit d732db7

Please sign in to comment.