Skip to content

Commit

Permalink
Fix: user 관련 타입 (#17)
Browse files Browse the repository at this point in the history
  • Loading branch information
minchodang authored May 14, 2024
1 parent 114e855 commit 2ea1465
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/modules/user/entities/user.entity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { Entity, Column, PrimaryGeneratedColumn } from 'typeorm';
@Entity()
export class User {
@PrimaryGeneratedColumn()
id: number;
id: string;

@Column()
email: string;
Expand Down
10 changes: 7 additions & 3 deletions src/modules/user/user.repository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,20 @@ import { DynamoDBDocument, QueryCommandOutput, GetCommandOutput, UpdateCommandOu
import * as bcrypt from 'bcrypt';
import { DatabaseError } from 'src/core/errors/database-error';
import { UserType } from 'src/types/userType';
import { User } from './entities/user.entity';

interface UserInfo {
id?: string;
email: string;
password: string;
[key: string]: string;
PK?: string;
SK?: string;
}

interface UserTest {
[key: string]: string;
PK?: string;
SK?: string;
}

@Injectable()
Expand Down Expand Up @@ -88,7 +92,7 @@ export class UserRepository {
}
}

async update(id: string, userInfo: Partial<UserInfo>): Promise<UserInfo | null> {
async update(id: string, userInfo: Partial<UserInfo>): Promise<User | null> {
let updateExpression = 'set';
const ExpressionAttributeNames: { [key: string]: string } = {};
const ExpressionAttributeValues: { [key: string]: unknown } = {};
Expand All @@ -112,7 +116,7 @@ export class UserRepository {
ReturnValues: 'ALL_NEW', // return updated all data
});

return result.Attributes as UserInfo | null;
return result.Attributes as User | null;
} catch (e) {
throw new DatabaseError();
}
Expand Down
5 changes: 3 additions & 2 deletions src/modules/user/user.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,11 @@ export class UserService {
userInfo['nickname'] = nickName;
}

const item = await this.usersRepository.create({ ...userInfo, userType });
const item = await this.usersRepository.create(userInfo);

const responseItem = {
id: item.PK,
userType: userType, // Add this line
...item,
};
delete responseItem.PK;
Expand Down Expand Up @@ -119,7 +120,7 @@ async update(id: string, userInfo: UpdateUserInfoRequestDto): Promise<Omit<User,
const order = query.order;
const level = query.level;
const encodedStartKey = query.startKey;
let startKey: any;
let startKey: string;
if (encodedStartKey) {
const decodedString = Buffer.from(encodedStartKey, 'base64').toString(
'utf-8',
Expand Down

0 comments on commit 2ea1465

Please sign in to comment.