- 일정 상세 조회 기능 구현 중
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import { pgTable, foreignKey, uuid, text, date, boolean, varchar, index, time, primaryKey, pgSequence } from "drizzle-orm/pg-core"
|
||||
import { pgTable, varchar, date, boolean, timestamp, uuid, foreignKey, text, index, time, primaryKey, pgSequence } from "drizzle-orm/pg-core"
|
||||
import { sql } from "drizzle-orm"
|
||||
|
||||
|
||||
@@ -19,10 +19,23 @@ export const userBadgeIdSeq = pgSequence("user_badge_id_seq", { startWith: "1",
|
||||
export const userBlockingIdSeq = pgSequence("user_blocking_id_seq", { startWith: "1", increment: "1", minValue: "1", maxValue: "9223372036854775807", cache: "1", cycle: false })
|
||||
export const emailAddressIdSeq = pgSequence("email_address_id_seq", { startWith: "1", increment: "1", minValue: "1", maxValue: "9223372036854775807", cache: "1", cycle: false })
|
||||
|
||||
export const account = pgTable("account", {
|
||||
name: varchar().notNull(),
|
||||
email: varchar().notNull(),
|
||||
password: varchar().notNull(),
|
||||
birthday: date(),
|
||||
accountId: varchar("account_id").notNull(),
|
||||
nickname: varchar().notNull(),
|
||||
status: varchar().default('active').notNull(),
|
||||
isDeleted: boolean("is_deleted").default(false).notNull(),
|
||||
createdAt: timestamp("created_at", { mode: 'string' }).defaultNow().notNull(),
|
||||
id: uuid().default(sql`uuid_generate_v4()`).primaryKey().notNull(),
|
||||
});
|
||||
|
||||
export const comment = pgTable("comment", {
|
||||
id: uuid().default(sql`uuid_generate_v4()`).primaryKey().notNull(),
|
||||
content: text(),
|
||||
createdAt: date("created_at"),
|
||||
createdAt: timestamp("created_at", { mode: 'string' }),
|
||||
isDeleted: boolean("is_deleted").default(false),
|
||||
writerId: uuid("writer_id"),
|
||||
parentId: uuid("parent_id"),
|
||||
@@ -39,19 +52,6 @@ export const comment = pgTable("comment", {
|
||||
}),
|
||||
]);
|
||||
|
||||
export const account = pgTable("account", {
|
||||
name: varchar().notNull(),
|
||||
email: varchar().notNull(),
|
||||
password: varchar().notNull(),
|
||||
birthday: date(),
|
||||
accountId: varchar("account_id").notNull(),
|
||||
nickname: varchar().notNull(),
|
||||
status: varchar().default('active').notNull(),
|
||||
isDeleted: boolean("is_deleted").default(false).notNull(),
|
||||
createdAt: date("created_at").defaultNow().notNull(),
|
||||
id: uuid().default(sql`uuid_generate_v4()`).primaryKey().notNull(),
|
||||
});
|
||||
|
||||
export const participant = pgTable("participant", {
|
||||
participantId: uuid("participant_id").notNull(),
|
||||
scheduleId: uuid("schedule_id").notNull(),
|
||||
@@ -80,7 +80,7 @@ export const schedule = pgTable("schedule", {
|
||||
content: text(),
|
||||
isDeleted: boolean("is_deleted").default(false).notNull(),
|
||||
type: varchar().notNull(),
|
||||
createdAt: date("created_at"),
|
||||
createdAt: timestamp("created_at", { mode: 'string' }).defaultNow().notNull(),
|
||||
owner: uuid().notNull(),
|
||||
style: varchar().notNull(),
|
||||
startTime: time("start_time").notNull(),
|
||||
@@ -122,7 +122,7 @@ export const follow = pgTable("follow", {
|
||||
isDeleted: boolean("is_deleted").default(false),
|
||||
isAccepted: boolean("is_accepted").default(false),
|
||||
isLinked: boolean("is_linked").default(false),
|
||||
createdAt: date("created_at"),
|
||||
createdAt: timestamp("created_at", { mode: 'string' }).defaultNow().notNull(),
|
||||
following: uuid().notNull(),
|
||||
follower: uuid().notNull(),
|
||||
}, (table) => [
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
"drizzle-pull:prod": "dotenv -e .env.prod -- drizzle-kit pull"
|
||||
},
|
||||
"dependencies": {
|
||||
"@baekyangdan/core-utils": "^1.0.4",
|
||||
"@baekyangdan/core-utils": "^1.0.9",
|
||||
"@fastify/cookie": "^11.0.2",
|
||||
"@nestjs/class-transformer": "^0.4.0",
|
||||
"@nestjs/class-validator": "^0.13.4",
|
||||
@@ -38,6 +38,7 @@
|
||||
"@nestjs/platform-express": "^11.0.1",
|
||||
"@nestjs/platform-fastify": "^11.1.9",
|
||||
"bcrypt": "^6.0.0",
|
||||
"date-fns": "^4.1.0",
|
||||
"dotenv": "^17.2.3",
|
||||
"drizzle-kit": "^0.31.7",
|
||||
"drizzle-orm": "^0.44.7",
|
||||
|
||||
@@ -6,7 +6,7 @@ export class AuthService {
|
||||
constructor(private readonly jwtService: JwtService) {}
|
||||
|
||||
generateTokens(id: string) {
|
||||
const accessToken = this.jwtService.sign({id: id}, { expiresIn: '1m' });
|
||||
const accessToken = this.jwtService.sign({id: id}, { expiresIn: '5m' });
|
||||
const refreshToken = this.jwtService.sign({id: id}, { expiresIn: '7d' });
|
||||
|
||||
return { accessToken, refreshToken };
|
||||
|
||||
@@ -5,67 +5,69 @@ import { Public } from "src/common/decorators/public.decorator";
|
||||
import type { FastifyReply, FastifyRequest } from "fastify";
|
||||
import { AuthGuard } from "@nestjs/passport";
|
||||
import { JwtAccessAuthGuard } from "src/middleware/auth/guard/access-token.guard";
|
||||
import { HttpApiUrl } from '@baekyangdan/core-utils';
|
||||
|
||||
const AccountApi = HttpApiUrl.Account;
|
||||
@UseGuards(JwtAccessAuthGuard)
|
||||
@Controller('account')
|
||||
@Controller(AccountApi.base)
|
||||
export class AccountController {
|
||||
constructor(private readonly accountService: AccountService) {}
|
||||
|
||||
@Get('/')
|
||||
@Get(AccountApi.root)
|
||||
async test() {
|
||||
return "Test"
|
||||
}
|
||||
|
||||
@Public()
|
||||
@Get('check-duplication')
|
||||
@Get(AccountApi.checkDuplication)
|
||||
async checkDuplication(@Query() query: DTO.CheckDuplicationRequest): Promise<DTO.CheckDuplicationResponse> {
|
||||
return await this.accountService.checkDuplication(query);
|
||||
}
|
||||
|
||||
@Public()
|
||||
@Post('send-email-verification-code')
|
||||
@Post(AccountApi.sendEmailVerificationCode)
|
||||
async sendEmailVerificationCode(@Body() body: DTO.SendEmailVerificationCodeRequest): Promise<DTO.SendEmailVerificationCodeResponse> {
|
||||
const result = await this.accountService.sendVerificationCode(body);
|
||||
return result;
|
||||
}
|
||||
|
||||
@Public()
|
||||
@Post('verify-email-verification-code')
|
||||
async verifyCode(@Body() body: DTO.VerifyEmailVerificationCodeRequest): Promise<DTO.VerifyEmailVerificationCodeResponse> {
|
||||
@Post(AccountApi.verifyEmailVerificationCode)
|
||||
async verifyEmailVerificationCode(@Body() body: DTO.VerifyEmailVerificationCodeRequest): Promise<DTO.VerifyEmailVerificationCodeResponse> {
|
||||
const result = await this.accountService.verifyCode(body);
|
||||
return result;
|
||||
}
|
||||
|
||||
@Public()
|
||||
@Post('send-reset-password-code')
|
||||
@Post(AccountApi.sendResetPasswordCode)
|
||||
async sendResetPasswordCode(@Body() body: DTO.SendResetPasswordCodeRequest): Promise<DTO.SendResetPasswordCodeResponse> {
|
||||
const result = await this.accountService.sendResetPasswordCode(body);
|
||||
return result;
|
||||
}
|
||||
|
||||
@Public()
|
||||
@Post('verify-reset-password-code')
|
||||
@Post(AccountApi.verifyResetPasswordCode)
|
||||
async verifyResetPasswordCode(@Body() body: DTO.VerifyResetPasswordCodeRequest): Promise<DTO.VerifyResetPasswordCodeResponse> {
|
||||
const result = await this.accountService.verifyResetPasswordCode(body);
|
||||
return result;
|
||||
}
|
||||
|
||||
@Public()
|
||||
@Post('reset-password')
|
||||
@Post(AccountApi.resetPassword)
|
||||
async resetPassword(@Body() body: DTO.ResetPasswordRequest): Promise<DTO.ResetPasswordResponse> {
|
||||
const result = await this.accountService.resetPassword(body);
|
||||
return result;
|
||||
}
|
||||
|
||||
@Public()
|
||||
@Post('signup')
|
||||
@Post(AccountApi.signup)
|
||||
async signup(@Body() body: DTO.SignupRequest): Promise<DTO.SignupResponse> {
|
||||
const result = await this.accountService.signup(body);
|
||||
return result;
|
||||
}
|
||||
|
||||
@Public()
|
||||
@Post('login')
|
||||
@Post(AccountApi.login)
|
||||
async login(@Body() body: DTO.LoginRequest, @Res({ passthrough: true }) res: FastifyReply): Promise<DTO.LoginResponse> {
|
||||
const result = await this.accountService.login(body);
|
||||
if (result.success) {
|
||||
@@ -86,7 +88,7 @@ export class AccountController {
|
||||
|
||||
@Public()
|
||||
@UseGuards(AuthGuard('refresh-token'))
|
||||
@Get('refresh-access-token')
|
||||
@Get(AccountApi.refreshAccessToken)
|
||||
async refreshAccessToken(@Req() req, @Res({ passthrough: true }) res: FastifyReply): Promise<DTO.RefreshAccessTokenResponse> {
|
||||
const result = await this.accountService.refreshAccessToken(req.user.id);
|
||||
if (result.success) {
|
||||
|
||||
@@ -2,24 +2,28 @@ import { Body, Controller, Get, Param, Post, Req, UseGuards } from "@nestjs/comm
|
||||
import { JwtAccessAuthGuard } from "src/middleware/auth/guard/access-token.guard";
|
||||
import { ScheduleService } from "./schedule.service";
|
||||
import * as DTO from './dto';
|
||||
import { HttpApiUrl } from "@baekyangdan/core-utils";
|
||||
|
||||
const ScheduleApi = HttpApiUrl.Schedule;
|
||||
|
||||
@UseGuards(JwtAccessAuthGuard)
|
||||
@Controller('schedule')
|
||||
@Controller(ScheduleApi.base)
|
||||
export class ScheduleController {
|
||||
constructor(private readonly scheduleService: ScheduleService) {}
|
||||
|
||||
@Post('/')
|
||||
@Post(ScheduleApi.getList)
|
||||
async getList(@Req() req, @Body() data: DTO.ListRequest): Promise<DTO.ListResponse> {
|
||||
const result = await this.scheduleService.getList(req.user.id, data);
|
||||
return result;
|
||||
}
|
||||
|
||||
@Get('/:id')
|
||||
@Get(ScheduleApi.getDetail)
|
||||
async getDetail(@Param('id') id: string): Promise<DTO.DetailResponse> {
|
||||
const result = await this.scheduleService.getDetail(id);
|
||||
return result;
|
||||
}
|
||||
|
||||
@Post('/create')
|
||||
@Post(ScheduleApi.create)
|
||||
async create(@Req() req, @Body() data: DTO.CreateRequest): Promise<DTO.CreateResponse> {
|
||||
const result = await this.scheduleService.create(req.user.id, data);
|
||||
return result;
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
import { Injectable } from "@nestjs/common";
|
||||
import { ScheduleRepo } from "./schedule.repo";
|
||||
import * as DTO from './dto';
|
||||
import { format } from "date-fns";
|
||||
import { DateFormat, TimeFormat } from "@baekyangdan/core-utils";
|
||||
import { ko } from "date-fns/locale";
|
||||
|
||||
@Injectable()
|
||||
export class ScheduleService {
|
||||
@@ -30,7 +33,8 @@ export class ScheduleService {
|
||||
const data = {
|
||||
...result[0],
|
||||
startDate: new Date(result[0].startDate),
|
||||
endDate: new Date(result[0].endDate)
|
||||
endDate: new Date(result[0].endDate),
|
||||
createdAt: format(result[0].createdAt, `${DateFormat.KOREAN} ${TimeFormat.KOREAN_SIMPLE}`, { locale: ko })
|
||||
}
|
||||
|
||||
return {
|
||||
|
||||
11
yarn.lock
11
yarn.lock
@@ -999,14 +999,14 @@ __metadata:
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"@baekyangdan/core-utils@npm:^1.0.4":
|
||||
version: 1.0.4
|
||||
resolution: "@baekyangdan/core-utils@npm:1.0.4::__archiveUrl=https%3A%2F%2Fgitea.bkdhome.p-e.kr%2Fapi%2Fpackages%2Fbaekyangdan%2Fnpm%2F%2540baekyangdan%252Fcore-utils%2F-%2F1.0.4%2Fcore-utils-1.0.4.tgz"
|
||||
"@baekyangdan/core-utils@npm:^1.0.9":
|
||||
version: 1.0.9
|
||||
resolution: "@baekyangdan/core-utils@npm:1.0.9::__archiveUrl=https%3A%2F%2Fgitea.bkdhome.p-e.kr%2Fapi%2Fpackages%2Fbaekyangdan%2Fnpm%2F%2540baekyangdan%252Fcore-utils%2F-%2F1.0.9%2Fcore-utils-1.0.9.tgz"
|
||||
dependencies:
|
||||
date-fns: "npm:^4.1.0"
|
||||
reflect-metadata: "npm:^0.2.2"
|
||||
tsup: "npm:^8.5.1"
|
||||
checksum: 10c0/d183abf8b42ca265ede259274ed773e013bb4f178a74552c11541283d92446c70e09e5bdf12cb35b1972deec9dda4290fd3514ad0eb283b8592456516a5f58cb
|
||||
checksum: 10c0/76c23a35dcc40856cd1be0b632a71ddbdb1740b397ddfcf4e2d8b307d0c127419382c0f89a0d92fc2546e9a3e313172d825942d78121d2d16cfde43a8729a7ca
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
@@ -4757,7 +4757,7 @@ __metadata:
|
||||
version: 0.0.0-use.local
|
||||
resolution: "back@workspace:."
|
||||
dependencies:
|
||||
"@baekyangdan/core-utils": "npm:^1.0.4"
|
||||
"@baekyangdan/core-utils": "npm:^1.0.9"
|
||||
"@eslint/eslintrc": "npm:^3.2.0"
|
||||
"@eslint/js": "npm:^9.18.0"
|
||||
"@fastify/cookie": "npm:^11.0.2"
|
||||
@@ -4785,6 +4785,7 @@ __metadata:
|
||||
"@types/supertest": "npm:^6.0.2"
|
||||
bcrypt: "npm:^6.0.0"
|
||||
cross-env: "npm:^10.1.0"
|
||||
date-fns: "npm:^4.1.0"
|
||||
dotenv: "npm:^17.2.3"
|
||||
dotenv-cli: "npm:^11.0.0"
|
||||
drizzle-kit: "npm:^0.31.7"
|
||||
|
||||
Reference in New Issue
Block a user