mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-19 06:10:31 +00:00
refactor(nestjs): attachments and s3 modules
This commit is contained in:
29
packages/server-nest/src/modules/S3/S3.module.ts
Normal file
29
packages/server-nest/src/modules/S3/S3.module.ts
Normal file
@@ -0,0 +1,29 @@
|
||||
import { Module } from '@nestjs/common';
|
||||
import { S3Client } from '@aws-sdk/client-s3';
|
||||
import { ConfigService } from '@nestjs/config';
|
||||
|
||||
export const S3_CLIENT = 'S3_CLIENT';
|
||||
|
||||
const services = [
|
||||
{
|
||||
provide: S3_CLIENT,
|
||||
useFactory: (configService: ConfigService) => {
|
||||
const config = configService.get('s3');
|
||||
|
||||
return new S3Client({
|
||||
region: config.region,
|
||||
credentials: {
|
||||
accessKeyId: config.accessKeyId,
|
||||
secretAccessKey: config.secretAccessKey,
|
||||
},
|
||||
endpoint: config.endpoint,
|
||||
forcePathStyle: config.forcePathStyle,
|
||||
});
|
||||
},
|
||||
},
|
||||
];
|
||||
@Module({
|
||||
providers: [...services],
|
||||
exports: [...services],
|
||||
})
|
||||
export class S3Module {}
|
||||
Reference in New Issue
Block a user