Skip to content

Commit

Permalink
Merge pull request #288 from tnpfldyd/BE-fix/api-server
Browse files Browse the repository at this point in the history
๋ถˆํ•„์š” ์ฝ”๋“œ ์‚ญ์ œ ๋ฐ private ์ ์šฉ
  • Loading branch information
Conut-1 authored Dec 13, 2023
2 parents f76a5b7 + 2685d0d commit 4dc84ee
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 18 deletions.
6 changes: 3 additions & 3 deletions nestjs-BE/server/src/auth/auth.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ export class AuthService extends BaseService<TokenData> {
return responseBody.kakao_account;
}

async createAccessToken(userUuid: string): Promise<string> {
private async createAccessToken(userUuid: string): Promise<string> {
const payload = { sub: userUuid };
const accessToken = await this.jwtService.signAsync(payload, {
secret: jwtConstants.accessSecret,
Expand All @@ -69,7 +69,7 @@ export class AuthService extends BaseService<TokenData> {
return accessToken;
}

async createRefreshToken(): Promise<Record<string, string>> {
private async createRefreshToken(): Promise<Record<string, string>> {
const refreshTokenUuid = generateUuid();
const refreshToken = await this.jwtService.signAsync(
{ uuid: refreshTokenUuid },
Expand All @@ -78,7 +78,7 @@ export class AuthService extends BaseService<TokenData> {
return { refreshToken, refreshTokenUuid };
}

createRefreshTokenData(refreshTokenUuid: string, userUuid: string) {
private createRefreshTokenData(refreshTokenUuid: string, userUuid: string) {
const currentDate = new Date();
const expiryDate = new Date(currentDate);
expiryDate.setDate(currentDate.getDate() + REFRESH_TOKEN_EXPIRY_DAYS);
Expand Down
5 changes: 2 additions & 3 deletions nestjs-BE/server/src/base/base.service.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Injectable, HttpException, HttpStatus } from '@nestjs/common';
import { HttpException, HttpStatus } from '@nestjs/common';
import {
PrismaServiceMySQL,
PrismaServiceMongoDB,
Expand All @@ -20,7 +20,6 @@ export interface HasUuid {
uuid?: string;
}

@Injectable()
export abstract class BaseService<T extends HasUuid> {
protected cache: LRUCache;
protected className: string;
Expand Down Expand Up @@ -148,7 +147,7 @@ export abstract class BaseService<T extends HasUuid> {
return databaseData;
}

stringToObject(key: string) {
private stringToObject(key: string) {
const obj = {};
const keyValuePairs = key.split('+');

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ export class ProfileSpaceController {
const { space_uuid } = createProfileSpaceDto;
const { joinData, profileData } =
await this.profileSpaceService.processData(userUuid, space_uuid);
const responseData = await this.profileSpaceService.create(joinData);
const responseData = await this.profileSpaceService.create(joinData, false);
const data = await this.spacesService.processData(space_uuid, profileData);
await this.profileSpaceService.put(userUuid, space_uuid, data);
return responseData;
Expand Down
9 changes: 2 additions & 7 deletions nestjs-BE/server/src/profile-space/profile-space.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,6 @@ export class ProfileSpaceService extends BaseService<UpdateProfileSpaceDto> {
return `space_uuid:${data.space_uuid}+profile_uuid:${data.profile_uuid}`;
}

async create(data: CreateProfileSpaceDto) {
const response = await super.create(data, false);
return response;
}

async processData(userUuid: string, spaceUuid: string) {
const profileResponse = await this.profilesService.findOne(userUuid);
const profileUuid = profileResponse.data?.uuid;
Expand Down Expand Up @@ -97,7 +92,7 @@ export class ProfileSpaceService extends BaseService<UpdateProfileSpaceDto> {
return filterSpaceUsers.length === 0;
}

async fetchUserSpacesFromCacheOrDB(
private async fetchUserSpacesFromCacheOrDB(
userUuid: string,
profileUuid: string,
): Promise<UpdateSpaceDto[]> {
Expand All @@ -118,7 +113,7 @@ export class ProfileSpaceService extends BaseService<UpdateProfileSpaceDto> {
return storeUserSpaces;
}

async fetchSpaceUsersFromCacheOrDB(
private async fetchSpaceUsersFromCacheOrDB(
spaceUuid: string,
): Promise<UpdateProfileDto[]> {
const cacheSpaceProfiles = this.spaceCache.get(spaceUuid);
Expand Down
2 changes: 1 addition & 1 deletion nestjs-BE/server/src/spaces/spaces.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ export class SpacesController {
const userUuid = req.user.uuid;
const { joinData, profileData } =
await this.profileSpaceService.processData(userUuid, spaceUuid);
this.profileSpaceService.create(joinData);
this.profileSpaceService.create(joinData, false);
const spaceData = response.data;
const data = { profileData, spaceData };
await this.profileSpaceService.put(userUuid, spaceUuid, data);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ export class TemporaryDatabaseService {
this.init();
}

async init() {
private async init() {
this.initializeDatabase();
await this.readDataFromFiles();
await this.executeBulkOperations();
Expand Down Expand Up @@ -133,14 +133,14 @@ export class TemporaryDatabaseService {
});
}

operation({ service, uniqueKey, command, data }: OperationData) {
private operation({ service, uniqueKey, command, data }: OperationData) {
const filePath = join(this.FOLDER_NAME, `${service}-${command}.csv`);
fs.appendFile(filePath, `${uniqueKey},${JSON.stringify(data)}\n`, 'utf8');
this.database.get(service).get(command).set(uniqueKey, data);
}

@Cron('0 */10 * * * *')
async executeBulkOperations() {
private async executeBulkOperations() {
for (const service of this.database.keys()) {
const serviceMap = this.database.get(service);
const prisma =
Expand Down

0 comments on commit 4dc84ee

Please sign in to comment.