Skip to content
Closed
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
1 change: 1 addition & 0 deletions graphile/graphile-settings/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ export const getGraphileSettings = (
awsAccessKey: cdn.awsAccessKey!,
awsSecretKey: cdn.awsSecretKey!,
minioEndpoint: cdn.minioEndpoint,
provider: cdn.provider,
});

const resolveUpload = uploader.resolveUpload.bind(uploader);
Expand Down
4 changes: 3 additions & 1 deletion graphile/graphile-upload-plugin/__tests__/plugin.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,9 @@ import gql from 'graphql-tag';
const SCHEMA = process.env.SCHEMA ?? 'app_public';
const sql = (f: string) => join(__dirname, '../sql', f);

// Use defaults with optional overrides
// Use defaults with optional overrides.
// Defaults are MinIO‑style (provider: 'minio', localhost endpoint),
// which is suitable for local/CI test environments.
const config = getEnvOptions({
cdn: {
bucketName: 'test-upload-bucket'
Expand Down
5 changes: 4 additions & 1 deletion graphile/graphile-upload-plugin/src/resolvers/upload.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ export interface UploaderOptions {
awsSecretKey: string;
awsAccessKey: string;
minioEndpoint?: string;
provider?: 's3' | 'minio' | string;
}

export class Uploader {
Expand All @@ -18,7 +19,8 @@ export class Uploader {
awsRegion,
awsSecretKey,
awsAccessKey,
minioEndpoint
minioEndpoint,
provider
} = this.opts;

this.streamerInstance = new streamer({
Expand All @@ -27,6 +29,7 @@ export class Uploader {
awsSecretKey,
awsAccessKey,
minioEndpoint,
provider
});
}

Expand Down
1 change: 1 addition & 0 deletions graphql/env/__fixtures__/env.keys.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
"AWS_ACCESS_KEY_ID",
"AWS_SECRET_KEY",
"AWS_SECRET_ACCESS_KEY",
"BUCKET_PROVIDER",
"MINIO_ENDPOINT",
"DEPLOYMENT_USE_TX",
"DEPLOYMENT_FAST",
Expand Down
4 changes: 3 additions & 1 deletion graphql/explorer/src/resolvers/uploads.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ interface UploaderOptions {
awsSecretKey: string;
awsAccessKey: string;
minioEndpoint?: string;
provider?: 's3' | 'minio' | string;
}

interface Upload {
Expand All @@ -32,7 +33,8 @@ export class UploadHandler {
awsRegion: options.awsRegion,
awsSecretKey: options.awsSecretKey,
awsAccessKey: options.awsAccessKey,
minioEndpoint: options.minioEndpoint
minioEndpoint: options.minioEndpoint,
provider: options.provider
});
}

Expand Down
1 change: 1 addition & 0 deletions pgpm/env/__fixtures__/env.keys.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
"AWS_ACCESS_KEY_ID",
"AWS_SECRET_KEY",
"AWS_SECRET_ACCESS_KEY",
"BUCKET_PROVIDER",
"MINIO_ENDPOINT",
"DEPLOYMENT_USE_TX",
"DEPLOYMENT_FAST",
Expand Down
1 change: 1 addition & 0 deletions pgpm/env/__tests__/__snapshots__/merge.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ exports[`getEnvOptions merges defaults, config, env, and overrides 1`] = `
"awsSecretKey": "minioadmin",
"bucketName": "test-bucket",
"minioEndpoint": "http://localhost:9000",
"provider": "minio",
},
"db": {
"connections": {
Expand Down
2 changes: 2 additions & 0 deletions pgpm/env/src/env.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ export const getEnvVars = (): PgpmOptions => {
AWS_SECRET_KEY,
AWS_SECRET_ACCESS_KEY,
MINIO_ENDPOINT,
BUCKET_PROVIDER,

DEPLOYMENT_USE_TX,
DEPLOYMENT_FAST,
Expand Down Expand Up @@ -121,6 +122,7 @@ export const getEnvVars = (): PgpmOptions => {
...(PGDATABASE && { database: PGDATABASE }),
},
cdn: {
...(BUCKET_PROVIDER && { provider: BUCKET_PROVIDER as any }),
...(BUCKET_NAME && { bucketName: BUCKET_NAME }),
...(AWS_REGION && { awsRegion: AWS_REGION }),
...((AWS_ACCESS_KEY || AWS_ACCESS_KEY_ID) && { awsAccessKey: AWS_ACCESS_KEY || AWS_ACCESS_KEY_ID }),
Expand Down
10 changes: 10 additions & 0 deletions pgpm/types/src/pgpm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,13 @@ export interface ServerOptions {
* CDN and file storage configuration
*/
export interface CDNOptions {
/**
* CDN / object storage provider.
* - 's3' → AWS S3 (default)
* - 'minio' → MinIO / S3‑compatible endpoint
* - string → reserved for future providers
*/
provider?: 's3' | 'minio' | string;
/** S3 bucket name for file storage */
bucketName?: string;
/** AWS region for S3 bucket */
Expand Down Expand Up @@ -241,6 +248,9 @@ export const pgpmDefaults: PgpmOptions = {
strictAuth: false,
},
cdn: {
// Defaults are MinIO‑style for local/dev;
// production should override via BUCKET_PROVIDER=s3.
provider: 'minio',
bucketName: 'test-bucket',
awsRegion: 'us-east-1',
awsAccessKey: 'minioadmin',
Expand Down
2 changes: 2 additions & 0 deletions uploads/s3-streamer/__tests__/uploads.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ import { getClient, Streamer, upload } from '../src';
import type { AsyncUploadResult } from '../src/utils';

// Use Constructive defaults with optional overrides
// Defaults are MinIO‑style (provider: 'minio', localhost endpoint),
// which is suitable for local/CI test environments.
const config = getEnvOptions({
cdn: {
bucketName: 'test-bucket'
Expand Down
13 changes: 12 additions & 1 deletion uploads/s3-streamer/src/s3.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,21 @@ interface S3Options {
awsSecretKey: string;
awsRegion: string;
minioEndpoint?: string;
/**
* Object storage provider.
* - 's3' → AWS S3 (default)
* - 'minio' → MinIO / S3‑compatible endpoint
* If omitted, presence of `minioEndpoint` will imply MinIO for
* backwards compatibility.
*/
provider?: 's3' | 'minio' | string;
}

export default function getS3(opts: S3Options): S3Client {
const isMinio = Boolean(opts.minioEndpoint);
// Prefer explicit provider; fall back to endpoint for legacy callers
const isMinio =
opts.provider === 'minio' ||
(!opts.provider && Boolean(opts.minioEndpoint));

const awsConfig: S3ClientConfig = {
region: opts.awsRegion,
Expand Down
5 changes: 4 additions & 1 deletion uploads/s3-streamer/src/streamer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ interface StreamerOptions {
awsSecretKey: string;
awsAccessKey: string;
minioEndpoint?: string;
provider?: 's3' | 'minio' | string;
defaultBucket: string;
}

Expand All @@ -28,13 +29,15 @@ export class Streamer {
awsSecretKey,
awsAccessKey,
minioEndpoint,
provider,
defaultBucket
}: StreamerOptions) {
this.s3 = getS3({
awsRegion,
awsSecretKey,
awsAccessKey,
minioEndpoint
minioEndpoint,
provider
});
this.defaultBucket = defaultBucket;
}
Expand Down