Skip to content

Commit

Permalink
Merge branch 'stage' into feat/sentry
Browse files Browse the repository at this point in the history
  • Loading branch information
Ho-s authored Jun 29, 2024
2 parents c29d3e4 + 865656a commit 3e6db4b
Show file tree
Hide file tree
Showing 19 changed files with 422 additions and 122 deletions.
4 changes: 2 additions & 2 deletions src/auth/auth.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,12 @@ export class AuthController {
});

res.cookie('Authorization', 'Bearer ' + user.accessToken, {
// httpOnly: true,
httpOnly: true,
sameSite: 'none',
secure: true,
path: '/',
maxAge: 360000,
domain: 'api-dev.korrk.kr',
domain: '.vercel.app',
});

return res.redirect(302, this.configService.get('CLIENT_URL'));
Expand Down
6 changes: 5 additions & 1 deletion src/entities/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { GroupMap } from './group-map.entity';
import { KakaoPlace } from './kakao-place.entity';
import { UserMap } from './user-map.entity';
import { User } from './user.entity';

Expand All @@ -11,4 +12,7 @@ export * from './user-map.repository';
export * from './user.entity';
export * from './user.repository';

export const entities = [User, GroupMap, UserMap];
export * from './kakao-place.entity';
export * from './kakao-place.repository';

export const entities = [User, GroupMap, UserMap, KakaoPlace];
58 changes: 58 additions & 0 deletions src/entities/kakao-place.entity.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
import {
Entity,
EntityRepositoryType,
PrimaryKey,
Property,
} from '@mikro-orm/core';

import { KakaoPlaceRepository } from './kakao-place.repository';

@Entity({
comment: '카카오맵에서 제공하는 장소',
repository: () => KakaoPlaceRepository,
})
export class KakaoPlace {
@PrimaryKey({
type: 'integer',
comment: '카카오맵에서 제공하는 장소의 ID (basicInfo.cid)',
})
id: number;

@Property({
type: 'string',
comment: '카카오맵 basicInfo.placenamefull',
})
name: string;

@Property({
type: 'string',
comment: '카카오맵 basicInfo.category.cate1name',
})
category: string;

@Property({
type: 'string',
comment: '카카오맵 basicInfo.address.newaddr.newaddrfull',
})
address: string;

@Property({
type: 'json',
comment: '카카오맵 menuInfo.menuList',
})
menuList: { menu: string; price: string }[];

@Property({
type: 'json',
comment: '카카오맵 basicInfo.photo.photoList',
})
photoList: string[];

@Property()
createdAt: Date = new Date();

@Property({ onUpdate: () => new Date() })
updatedAt: Date = new Date();

[EntityRepositoryType]: KakaoPlaceRepository;
}
5 changes: 5 additions & 0 deletions src/entities/kakao-place.repository.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { ExtendedEntityRepository } from 'src/common/helper/extended-repository.helper';

import { KakaoPlace } from './kakao-place.entity';

export class KakaoPlaceRepository extends ExtendedEntityRepository<KakaoPlace> {}
12 changes: 11 additions & 1 deletion src/exceptions/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { HttpStatus } from '@nestjs/common';

import { createException } from './exception.factory';
import { ExceptionType } from './exception.type';

Expand All @@ -7,4 +9,12 @@ const ExceptionOf = {
EXTERNAL: createException(ExceptionType.EXTERNAL),
};

// export class UserNotFoundException extends ExceptionOf.USER(400, '존재하지 않는 유저입니다.' as const) {}
export class UserNotFoundException extends ExceptionOf.USER(
HttpStatus.NOT_FOUND,
'존재하지 않는 유저입니다.' as const,
) {}

export class DuplicateNicknameException extends ExceptionOf.USER(
HttpStatus.CONFLICT,
'이미 사용중인 닉네임입니다.' as const,
) {}
1 change: 1 addition & 0 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import * as Sentry from '@sentry/nestjs';
import { nodeProfilingIntegration } from '@sentry/profiling-node';
import cookieParser from 'cookie-parser';

import { CustomExceptionFilter } from 'src/core/exception-filters/custom-exception.filter';
import { ResponseInterceptor } from 'src/core/intercepters/response.intercepter';

import { AppModule } from './app.module';
Expand Down
24 changes: 12 additions & 12 deletions src/map/map.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import {
UniqueConstraintViolationException,
} from '@mikro-orm/core';
import { InjectRepository } from '@mikro-orm/nestjs';
import { EntityManager } from '@mikro-orm/postgresql';

import {
GroupMap,
Expand All @@ -22,13 +21,12 @@ import {

import { CreateMapDto } from './dtos/create-map.dto';
import { MapItemForUserDto } from './dtos/map-item-for-user.dto';
import { MapResponseDto, MapUser } from './dtos/map-response.dto';
import { MapResponseDto } from './dtos/map-response.dto';
import { UpdateMapDto } from './dtos/update-map.dto';

@Injectable()
export class MapService {
constructor(
private readonly em: EntityManager,
@InjectRepository(GroupMap)
private readonly mapRepository: GroupMapRepository,
@InjectRepository(UserMap)
Expand All @@ -40,16 +38,18 @@ export class MapService {
by: User,
): Promise<MapItemForUserDto> {
try {
const { map, userMap } = await this.em.transactional(async () => {
const map = this.mapRepository.create(createMapDto);
const userMap = this.userMapRepository.create({
user: by,
role: UserMapRole.ADMIN,
map,
});

return { map, userMap };
const map = this.mapRepository.create(createMapDto);
const userMap = this.userMapRepository.create({
user: by,
role: UserMapRole.ADMIN,
map,
});
this.mapRepository.persist(map);
this.userMapRepository.persist(userMap);

await this.mapRepository.flush();
// await this.userMapRepository.flush(); // 이거 왜 안하지?

const mapItemForUser = new MapItemForUserDto();
mapItemForUser.id = map.id;
mapItemForUser.name = map.name;
Expand Down
110 changes: 110 additions & 0 deletions src/migrations/.snapshot-korrk-stage.json
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,116 @@
}
}
},
{
"columns": {
"id": {
"name": "id",
"type": "int",
"unsigned": true,
"autoincrement": true,
"primary": true,
"nullable": false,
"comment": "카카오맵에서 제공하는 장소의 ID (basicInfo.cid)",
"mappedType": "integer"
},
"name": {
"name": "name",
"type": "varchar(255)",
"unsigned": false,
"autoincrement": false,
"primary": false,
"nullable": false,
"comment": "카카오맵 basicInfo.placenamefull",
"mappedType": "string"
},
"category": {
"name": "category",
"type": "varchar(255)",
"unsigned": false,
"autoincrement": false,
"primary": false,
"nullable": false,
"comment": "카카오맵 basicInfo.category.cate1name",
"mappedType": "string"
},
"address": {
"name": "address",
"type": "varchar(255)",
"unsigned": false,
"autoincrement": false,
"primary": false,
"nullable": false,
"comment": "카카오맵 basicInfo.address.newaddr.newaddrfull",
"mappedType": "string"
},
"menu_list": {
"name": "menu_list",
"type": "jsonb",
"unsigned": false,
"autoincrement": false,
"primary": false,
"nullable": false,
"comment": "카카오맵 menuInfo.menuList",
"mappedType": "json"
},
"photo_list": {
"name": "photo_list",
"type": "jsonb",
"unsigned": false,
"autoincrement": false,
"primary": false,
"nullable": false,
"comment": "카카오맵 basicInfo.photo.photoList",
"mappedType": "json"
},
"created_at": {
"name": "created_at",
"type": "timestamptz",
"unsigned": false,
"autoincrement": false,
"primary": false,
"nullable": false,
"length": 6,
"mappedType": "datetime"
},
"updated_at": {
"name": "updated_at",
"type": "timestamptz",
"unsigned": false,
"autoincrement": false,
"primary": false,
"nullable": false,
"length": 6,
"mappedType": "datetime"
}
},
"name": "kakao_place",
"schema": "public",
"indexes": [
{
"keyName": "kakao_place_pkey",
"columnNames": ["id"],
"composite": false,
"constraint": true,
"primary": true,
"unique": true
}
],
"checks": [],
"foreignKeys": {},
"nativeEnums": {
"user_provider": {
"name": "user_provider",
"schema": "public",
"items": ["KAKAO"]
},
"user_role": {
"name": "user_role",
"schema": "public",
"items": ["USER", "ADMIN"]
}
}
},
{
"columns": {
"id": {
Expand Down
31 changes: 31 additions & 0 deletions src/migrations/Migration20240629180004.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import { Migration } from '@mikro-orm/migrations';

export class Migration20240629180004 extends Migration {
async up(): Promise<void> {
this.addSql(
'create table "kakao_place" ("id" serial primary key, "name" varchar(255) not null, "category" varchar(255) not null, "address" varchar(255) not null, "menu_list" jsonb not null, "photo_list" jsonb not null, "created_at" timestamptz not null, "updated_at" timestamptz not null);',
);
this.addSql(
'comment on column "kakao_place"."id" is \'카카오맵에서 제공하는 장소의 ID (basicInfo.cid)\';',
);
this.addSql(
'comment on column "kakao_place"."name" is \'카카오맵 basicInfo.placenamefull\';',
);
this.addSql(
'comment on column "kakao_place"."category" is \'카카오맵 basicInfo.category.cate1name\';',
);
this.addSql(
'comment on column "kakao_place"."address" is \'카카오맵 basicInfo.address.newaddr.newaddrfull\';',
);
this.addSql(
'comment on column "kakao_place"."menu_list" is \'카카오맵 menuInfo.menuList\';',
);
this.addSql(
'comment on column "kakao_place"."photo_list" is \'카카오맵 basicInfo.photo.photoList\';',
);
}

async down(): Promise<void> {
this.addSql('drop table if exists "kakao_place" cascade;');
}
}
39 changes: 10 additions & 29 deletions src/search/kakao-map.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -157,42 +157,23 @@ export type KakaoPlaceDetailRaw = {
menuInfo: {
moreyn: string; // "Y"
menuList: {
'0': {
price: string; // "14,000"
recommend: boolean; // false
menu: string; // "구이양념막창"
};
'1': {
price: string; // "14,000"
recommend: boolean; // false
menu: string; // "소금구이막창"
};
'2': {
price: string; // "15,000"
recommend: boolean; // false
menu: string; // "야채곱창볶음"
};
'3': {
price: string; // "17,000"
recommend: boolean; // false
menu: string; // "순대곱창볶음"
};
};
price: string; // "14,000"
recommend: boolean; // false
menu: string; // "구이양념막창"
}[];
productyn: string; // "N"
menuboardphotourl: string; // "https://postfiles.pstatic.net/MjAyNDA2MTJfNzQg/MDAxNzE4MTQ3ODA5OTMw.zeLbX5XZ9nkUSuo38EpVkuEo7IXMWg9C4lIWASeTVB0g.q2QQTpKvHlOMQQk9osA0wYHWd2_qy6u0wiaWi1YlqNIg.JPEG/IMG_0736.jpg?type=w773"
menuboardphotocount: number; // 30
timeexp: string; // "2024.01.25."
};
photo: {
photoCount: number; // 335
photoList: {
photoid: string; // "M"
orgurl: string; // "http://t1.daumcdn.net/place/6DCE4A7D51924FE3A4437B8C91C553D4"
}[];
sortedPhotoList: {
photoid: string; // "Tfood935698273"
orgurl: string; // "https://postfiles.pstatic.net/MjAyNDAzMjBfOTAg/MDAxNzEwODkzMDAxNjQw.zqZaIHYTcWW3eQhusMhZEjwPfZDlbyztLXc-G_WOedUg.Z2QvhMnLfJahDnC5cquqpbfewKiLR_Wnb3NLmvy21skg.JPEG/IMG_3371.JPG?type=w966"
categoryName: string; // "음식"
photoCount: number; // 335
categoryName: string; // "all"
list: {
photoid: string; // "M"
orgurl: string; // "http://t1.daumcdn.net/place/6DCE4A7D51924FE3A4437B8C91C553D4"
}[];
}[];
};
placeSubscribeInfo: {
Expand Down
Loading

0 comments on commit 3e6db4b

Please sign in to comment.