Skip to content

Commit

Permalink
fix: allow s3 endpoints
Browse files Browse the repository at this point in the history
  • Loading branch information
diced committed Dec 20, 2024
1 parent 12fcff1 commit a55a43d
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 7 deletions.
2 changes: 2 additions & 0 deletions src/lib/config/read.ts
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@ export const PROP_TO_ENV = {
'datasource.s3.secretAccessKey': 'DATASOURCE_S3_SECRET_ACCESS_KEY',
'datasource.s3.region': 'DATASOURCE_S3_REGION',
'datasource.s3.bucket': 'DATASOURCE_S3_BUCKET',
'datasource.s3.endpoint': 'DATASOURCE_S3_ENDPOINT',

'datasource.local.directory': 'DATASOURCE_LOCAL_DIRECTORY',

Expand Down Expand Up @@ -319,6 +320,7 @@ export function readEnv() {
env('datasource.s3.secretAccessKey', 'string'),
env('datasource.s3.region', 'string'),
env('datasource.s3.bucket', 'string'),
env('datasource.s3.endpoint', 'string'),

env('datasource.local.directory', 'string'),

Expand Down
1 change: 1 addition & 0 deletions src/lib/config/validate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ export const schema = z.object({
secretAccessKey: z.string(),
region: z.string(),
bucket: z.string(),
endpoint: z.string().nullable().default(null),
})
.optional(),
local: z
Expand Down
4 changes: 4 additions & 0 deletions src/lib/datasource/S3.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,20 @@ export class S3Datasource extends Datasource {
secretAccessKey: string;
region?: string;
bucket: string;
endpoint?: string | null;
},
) {
super();

console.log(options);

this.client = new S3Client({
credentials: {
accessKeyId: this.options.accessKeyId,
secretAccessKey: this.options.secretAccessKey,
},
region: this.options.region ?? undefined,
endpoint: this.options.endpoint ?? undefined,
});

this.ensureBucketExists();
Expand Down
1 change: 1 addition & 0 deletions src/lib/datasource/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ function getDatasource(conf?: typeof config): void {
secretAccessKey: config.datasource.s3!.secretAccessKey,
region: config.datasource.s3?.region,
bucket: config.datasource.s3!.bucket,
endpoint: config.datasource.s3?.endpoint,
});
break;
default:
Expand Down
7 changes: 0 additions & 7 deletions src/server/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -225,10 +225,3 @@ declare module 'fastify' {
tasks: Tasks;
}
}

process.on('unhandledRejection', (reason, promise) => {
console.log('AAA', reason, promise);
});
process.on('uncaughtException', (reason) => {
console.log('aaa', reason);
});

0 comments on commit a55a43d

Please sign in to comment.