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
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,5 @@ postgres/pgsql-test/output/
.claude
.kiro
*.tsbuildinfo
.env
.env.local
13 changes: 0 additions & 13 deletions graphql/server/.env

This file was deleted.

1 change: 0 additions & 1 deletion graphql/server/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@
"@pgpmjs/server-utils": "workspace:^",
"@pgpmjs/types": "workspace:^",
"cors": "^2.8.5",
"dotenv": "^17.2.3",
"express": "^5.1.0",
"graphile-build": "^4.14.1",
"graphile-cache": "workspace:^",
Expand Down
33 changes: 15 additions & 18 deletions graphql/server/src/scripts/create-bucket.ts
Original file line number Diff line number Diff line change
@@ -1,36 +1,33 @@
// Minimal script to create a bucket in MinIO using @constructive-io/s3-utils
// Avoid strict type coupling between different @aws-sdk/client-s3 versions

// Loads graphql/server/.env by default when running via ts-node from this workspace
import 'dotenv/config';

import { S3Client } from '@aws-sdk/client-s3';
import { createS3Bucket } from '@constructive-io/s3-utils';

const BUCKET = process.env.BUCKET_NAME || 'test-bucket';
const REGION = process.env.AWS_REGION || 'us-east-1';
const ACCESS_KEY =
process.env.AWS_ACCESS_KEY || process.env.AWS_ACCESS_KEY_ID || 'minioadmin';
const SECRET_KEY =
process.env.AWS_SECRET_KEY ||
process.env.AWS_SECRET_ACCESS_KEY ||
'minioadmin';
const ENDPOINT = process.env.MINIO_ENDPOINT || 'http://localhost:9000';
import { getEnvOptions } from '@constructive-io/graphql-env';

(async () => {
try {
const opts = getEnvOptions();
const { cdn } = opts;

const bucket = cdn?.bucketName || 'test-bucket';
const region = cdn?.awsRegion || 'us-east-1';
const accessKey = cdn?.awsAccessKey || 'minioadmin';
const secretKey = cdn?.awsSecretKey || 'minioadmin';
const endpoint = cdn?.minioEndpoint || 'http://localhost:9000';

const client: any = new S3Client({
region: REGION,
credentials: { accessKeyId: ACCESS_KEY, secretAccessKey: SECRET_KEY },
endpoint: ENDPOINT,
region,
credentials: { accessKeyId: accessKey, secretAccessKey: secretKey },
endpoint,
forcePathStyle: true,
});

// Hint downstream to apply MinIO policies
process.env.IS_MINIO = 'true';

const res = await createS3Bucket(client as any, BUCKET);
console.log(`[create-bucket] ${BUCKET}:`, res);
const res = await createS3Bucket(client as any, bucket);
console.log(`[create-bucket] ${bucket}:`, res);

client.destroy();
} catch (e) {
Expand Down
2 changes: 0 additions & 2 deletions graphql/server/src/server.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import 'dotenv/config';

import { getEnvOptions } from '@constructive-io/graphql-env';
import { Logger } from '@pgpmjs/logger';
import { healthz, poweredBy, trustProxy } from '@pgpmjs/server-utils';
Expand Down
6 changes: 4 additions & 2 deletions pgpm/env/src/env.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,9 @@ export const getEnvVars = (): PgpmOptions => {
BUCKET_NAME,
AWS_REGION,
AWS_ACCESS_KEY,
AWS_ACCESS_KEY_ID,
AWS_SECRET_KEY,
AWS_SECRET_ACCESS_KEY,
MINIO_ENDPOINT,

DEPLOYMENT_USE_TX,
Expand Down Expand Up @@ -121,8 +123,8 @@ export const getEnvVars = (): PgpmOptions => {
cdn: {
...(BUCKET_NAME && { bucketName: BUCKET_NAME }),
...(AWS_REGION && { awsRegion: AWS_REGION }),
...(AWS_ACCESS_KEY && { awsAccessKey: AWS_ACCESS_KEY }),
...(AWS_SECRET_KEY && { awsSecretKey: AWS_SECRET_KEY }),
...((AWS_ACCESS_KEY || AWS_ACCESS_KEY_ID) && { awsAccessKey: AWS_ACCESS_KEY || AWS_ACCESS_KEY_ID }),
...((AWS_SECRET_KEY || AWS_SECRET_ACCESS_KEY) && { awsSecretKey: AWS_SECRET_KEY || AWS_SECRET_ACCESS_KEY }),
...(MINIO_ENDPOINT && { minioEndpoint: MINIO_ENDPOINT }),
},
deployment: {
Expand Down
Loading