Skip to content

Commit

Permalink
feat : object storage를 관리하기 위한 모듈 및 서비스 생성 #35
Browse files Browse the repository at this point in the history
- aws 모듈,서비스 생성
- s3 객체 인스턴스 생성

Co-authored-by: GeunH <[email protected]>
  • Loading branch information
LeeTH916 and GeunH committed Nov 30, 2023
1 parent 5df4878 commit 28f09b2
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 1 deletion.
2 changes: 1 addition & 1 deletion be/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

#config
typeorm.config.ts
objectStorage.config.json
objectStorage.config.ts

# Logs
logs
Expand Down
2 changes: 2 additions & 0 deletions be/src/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { ReviewModule } from "./review/review.module";
import { CustomLoggerService } from "./custom.logger";
import { APP_INTERCEPTOR } from "@nestjs/core";
import { LoggingInterceptor } from "./logger.interceptor";
import { AwsModule } from './aws/aws.module';

@Module({
imports: [
Expand All @@ -16,6 +17,7 @@ import { LoggingInterceptor } from "./logger.interceptor";
AuthModule,
RestaurantModule,
ReviewModule,
AwsModule,
],
providers: [
CustomLoggerService,
Expand Down
9 changes: 9 additions & 0 deletions be/src/aws/aws.module.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { Global, Module } from '@nestjs/common';
import { AwsService } from './aws.service';

@Global()
@Module({
providers: [AwsService],
exports: [AwsService],
})
export class AwsModule {}
18 changes: 18 additions & 0 deletions be/src/aws/aws.service.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { Test, TestingModule } from '@nestjs/testing';
import { AwsService } from './aws.service';

describe('AwsService', () => {
let service: AwsService;

beforeEach(async () => {
const module: TestingModule = await Test.createTestingModule({
providers: [AwsService],
}).compile();

service = module.get<AwsService>(AwsService);
});

it('should be defined', () => {
expect(service).toBeDefined();
});
});
19 changes: 19 additions & 0 deletions be/src/aws/aws.service.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { Injectable } from '@nestjs/common';
import * as AWS from 'aws-sdk';
import { awsConfig } from 'objectStorage.config';

@Injectable()
export class AwsService {
private s3: AWS.S3;

constructor() {
this.s3 = new AWS.S3({
endpoint: awsConfig.endpoint,
region: awsConfig.region,
credentials: {
accessKeyId: awsConfig.accessKey,
secretAccessKey: awsConfig.secretKey
},
});
}
}

0 comments on commit 28f09b2

Please sign in to comment.