Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion src/documents/documents.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ import { AuthModule } from '../auth/auth.module';
import { SignedUrlService } from './signed-url/signed-url.service';
import { NotConfiguredSignedUrlProvider } from './signed-url/not-configured.signed-url-provider';
import { S3SignedUrlProvider } from './signed-url/s3-signed-url-provider';
import { GcsSignedUrlProvider } from './signed-url/gcs-signed-url-provider';
import { AzureSignedUrlProvider } from './signed-url/azure-signed-url-provider';
import { DocumentsDownloadController } from './documents-download.controller';
import { SignedUrlProvider } from './signed-url/signed-url-provider.interface';

Expand All @@ -18,14 +20,20 @@ export const SIGNED_URL_PROVIDER_TOKEN = 'SIGNED_URL_PROVIDER_TOKEN';
* SIGNED_URL_PROVIDER environment variable.
*
* Supported values:
* - 's3' -> S3SignedUrlProvider (requires AWS credentials)
* - 's3' -> S3SignedUrlProvider (no-op shell for integrators)
* - 'gcs' -> GcsSignedUrlProvider (no-op shell for integrators)
* - 'azure' -> AzureSignedUrlProvider (no-op shell for integrators)
* - (unset/other) -> NotConfiguredSignedUrlProvider (throws a configured error)
*/
function signedUrlProviderFactory(): new (...args: any[]) => SignedUrlProvider {
const provider = process.env.SIGNED_URL_PROVIDER?.toLowerCase();
switch (provider) {
case 's3':
return S3SignedUrlProvider;
case 'gcs':
return GcsSignedUrlProvider;
case 'azure':
return AzureSignedUrlProvider;
default:
return NotConfiguredSignedUrlProvider;
}
Expand Down
23 changes: 23 additions & 0 deletions src/documents/signed-url/azure-signed-url-provider.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
// @ts-nocheck

import { Injectable } from '@nestjs/common';
import {
SignedUrlProvider,
SignedUrlRequest,
SignedUrlResponse,
} from './signed-url-provider.interface';

/**
* Placeholder strategy for Azure Blob Storage signed URLs.
* This shell intentionally throws until an integrator wires in a real implementation.
*/
@Injectable()
export class AzureSignedUrlProvider implements SignedUrlProvider {
isConfigured(): boolean {
return false;
}

async getSignedUrl(_req: SignedUrlRequest): Promise<SignedUrlResponse> {
throw new Error('Azure signed URL provider is not configured.');
}
}
23 changes: 23 additions & 0 deletions src/documents/signed-url/gcs-signed-url-provider.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
// @ts-nocheck

import { Injectable } from '@nestjs/common';
import {
SignedUrlProvider,
SignedUrlRequest,
SignedUrlResponse,
} from './signed-url-provider.interface';

/**
* Placeholder strategy for Google Cloud Storage signed URLs.
* This shell intentionally throws until an integrator wires in a real implementation.
*/
@Injectable()
export class GcsSignedUrlProvider implements SignedUrlProvider {
isConfigured(): boolean {
return false;
}

async getSignedUrl(_req: SignedUrlRequest): Promise<SignedUrlResponse> {
throw new Error('GCS signed URL provider is not configured.');
}
}
17 changes: 4 additions & 13 deletions src/documents/signed-url/s3-signed-url-provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,25 +8,16 @@ import {
} from './signed-url-provider.interface';

/**
* Placeholder for AWS S3 signed URLs.
* Intentionally throws if required env vars are missing.
* Placeholder strategy for AWS S3 signed URLs.
* This shell intentionally throws until an integrator wires in a real implementation.
*/
@Injectable()
export class S3SignedUrlProvider implements SignedUrlProvider {
isConfigured(): boolean {
return Boolean(
process.env.AWS_S3_BUCKET &&
process.env.AWS_ACCESS_KEY_ID &&
process.env.AWS_SECRET_ACCESS_KEY,
);
return false;
}

async getSignedUrl(_req: SignedUrlRequest): Promise<SignedUrlResponse> {
if (!this.isConfigured()) {
throw new Error('S3SignedUrlProvider not configured');
}

// Placeholder: implement via AWS SDK v3 once you wire credentials.
throw new Error('S3 signed URL not implemented yet');
throw new Error('S3 signed URL provider is not configured.');
}
}
Loading