Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions @types/environment.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,8 @@ declare namespace NodeJS {
export interface ProcessEnv extends NodeJS.ProcessEnv {
PORT: string;
DATABASE_URL: string;
PASSPORT_KAKAO_CLIENT_ID: string;
PASSPORT_KAKAO_CLIENT_SECRET: string;
EXPRESS_SESSION_SECRET: string;
}
}
2 changes: 2 additions & 0 deletions @types/express.d.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import 'express';
import {UserModel} from 'src/models/user.model.ts';

declare global {
namespace Express {
export interface User extends UserModel {}
export interface Response {
success(success: any): this;
error(error: {
Expand Down
14 changes: 13 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,22 +25,34 @@
"license": "ISC",
"dependencies": {
"@prisma/client": "^6.1.0",
"@quixo3/prisma-session-store": "^3.1.13",
"@tsoa/runtime": "^6.6.0",
"cookie-parser": "^1.4.7",
"cors": "^2.8.5",
"dotenv": "^16.4.7",
"express": "^5.0.0-0",
"express-session": "^1.18.1",
"http-status-codes": "^2.3.0",
"mqtt": "^5.11.1",
"passport": "^0.7.0",
"passport-kakao": "^1.0.1",
"prisma": "^6.1.0",
"swagger-jsdoc": "^6.2.8",
"swagger-ui-express": "^5.0.1"
"swagger-ui-express": "^5.0.1",
"ws": "^8.18.1"
},
"devDependencies": {
"@tsconfig/node20": "^20.1.4",
"@types/cookie-parser": "^1.4.8",
"@types/cors": "^2.8.17",
"@types/express": "^5.0.0",
"@types/express-session": "^1.18.1",
"@types/node": "^22.7.5",
"@types/passport": "^1.0.17",
"@types/passport-kakao": "^1.0.3",
"@types/swagger-jsdoc": "^6.0.4",
"@types/swagger-ui-express": "^4.1.7",
"@types/ws": "^8.18.1",
"esbuild": "^0.24.2",
"esbuild-plugin-copy": "^2.1.1",
"eslint": "^9.17.0",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
-- CreateTable
CREATE TABLE `users` (
`id` BIGINT NOT NULL AUTO_INCREMENT,
`email` VARCHAR(50) NOT NULL,
`name` VARCHAR(30) NOT NULL,
`created_at` TIMESTAMP(6) NOT NULL DEFAULT CURRENT_TIMESTAMP(6),
`updated_at` TIMESTAMP(6) NULL,
`status` TINYINT NOT NULL DEFAULT 1,

UNIQUE INDEX `email`(`email`),
PRIMARY KEY (`id`)
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;

-- CreateTable
CREATE TABLE `social_accounts` (
`id` BIGINT NOT NULL AUTO_INCREMENT,
`provider` VARCHAR(30) NOT NULL,
`provider_user_id` VARCHAR(255) NOT NULL,
`created_at` TIMESTAMP(6) NOT NULL DEFAULT CURRENT_TIMESTAMP(6),
`updated_at` TIMESTAMP(6) NULL,
`status` TINYINT NOT NULL DEFAULT 1,
`user_id` BIGINT NOT NULL,

PRIMARY KEY (`id`)
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;

-- CreateTable
CREATE TABLE `session` (
`id` VARCHAR(255) NOT NULL,
`sid` VARCHAR(255) NOT NULL,
`data` VARCHAR(512) NOT NULL,
`expires_at` TIMESTAMP(3) NOT NULL,

UNIQUE INDEX `session_sid_key`(`sid`),
PRIMARY KEY (`id`)
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;

-- AddForeignKey
ALTER TABLE `social_accounts` ADD CONSTRAINT `social_accounts_user_id_fkey` FOREIGN KEY (`user_id`) REFERENCES `users`(`id`) ON DELETE CASCADE ON UPDATE CASCADE;
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
/*
Warnings:

- You are about to drop the `social_accounts` table. If the table is not empty, all the data it contains will be lost.
- You are about to drop the `users` table. If the table is not empty, all the data it contains will be lost.

*/
-- DropForeignKey
ALTER TABLE `social_accounts` DROP FOREIGN KEY `social_accounts_user_id_fkey`;

-- DropTable
DROP TABLE `social_accounts`;

-- DropTable
DROP TABLE `users`;

-- CreateTable
CREATE TABLE `user` (
`id` BIGINT NOT NULL AUTO_INCREMENT,
`email` VARCHAR(50) NOT NULL,
`name` VARCHAR(30) NOT NULL,
`created_at` TIMESTAMP(6) NOT NULL DEFAULT CURRENT_TIMESTAMP(6),
`updated_at` TIMESTAMP(6) NULL,
`status` TINYINT NOT NULL DEFAULT 1,

UNIQUE INDEX `email`(`email`),
PRIMARY KEY (`id`)
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;

-- CreateTable
CREATE TABLE `social_account` (
`id` BIGINT NOT NULL AUTO_INCREMENT,
`provider` VARCHAR(30) NOT NULL,
`provider_user_id` VARCHAR(255) NOT NULL,
`created_at` TIMESTAMP(6) NOT NULL DEFAULT CURRENT_TIMESTAMP(6),
`updated_at` TIMESTAMP(6) NULL,
`status` TINYINT NOT NULL DEFAULT 1,
`user_id` BIGINT NOT NULL,

PRIMARY KEY (`id`)
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;

-- AddForeignKey
ALTER TABLE `social_account` ADD CONSTRAINT `social_account_user_id_fkey` FOREIGN KEY (`user_id`) REFERENCES `user`(`id`) ON DELETE CASCADE ON UPDATE CASCADE;
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
/*
Warnings:

- Added the required column `nickname` to the `user` table without a default value. This is not possible if the table is not empty.

*/
-- AlterTable
ALTER TABLE `user` ADD COLUMN `nickname` VARCHAR(30) NOT NULL,
ADD COLUMN `user_group_id` BIGINT NULL;

-- CreateTable
CREATE TABLE `group` (
`id` BIGINT NOT NULL AUTO_INCREMENT,
`name` VARCHAR(30) NOT NULL,
`created_at` TIMESTAMP(6) NOT NULL DEFAULT CURRENT_TIMESTAMP(6),
`updated_at` TIMESTAMP(6) NULL,
`status` TINYINT NOT NULL DEFAULT 1,

PRIMARY KEY (`id`)
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;

-- CreateTable
CREATE TABLE `user_group` (
`id` BIGINT NOT NULL AUTO_INCREMENT,
`userId` BIGINT NOT NULL,
`groupId` BIGINT NOT NULL,
`created_at` TIMESTAMP(6) NOT NULL DEFAULT CURRENT_TIMESTAMP(6),
`updated_at` TIMESTAMP(6) NULL,
`status` TINYINT NOT NULL DEFAULT 1,

UNIQUE INDEX `user_id`(`userId`),
UNIQUE INDEX `group_id`(`groupId`),
PRIMARY KEY (`id`)
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;

-- CreateTable
CREATE TABLE `todo` (
`id` BIGINT NOT NULL AUTO_INCREMENT,
`title` VARCHAR(50) NOT NULL,
`user_id` BIGINT NOT NULL,
`is_completed` TINYINT NOT NULL DEFAULT 1,
`start_time` DATETIME(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3),
`end_time` DATETIME(3) NULL,
`status` TINYINT NOT NULL DEFAULT 1,

PRIMARY KEY (`id`)
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;

-- CreateTable
CREATE TABLE `concentration` (
`id` BIGINT NOT NULL AUTO_INCREMENT,
`todo_id` BIGINT NOT NULL,
`hour` INTEGER NOT NULL,
`start_time` DATETIME(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3),
`end_time` DATETIME(3) NULL,
`status` TINYINT NOT NULL DEFAULT 1,

PRIMARY KEY (`id`)
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;

-- CreateTable
CREATE TABLE `focus_target` (
`id` BIGINT NOT NULL AUTO_INCREMENT,
`target` VARCHAR(50) NOT NULL,
`start_time` DATETIME(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3),
`end_time` DATETIME(3) NULL,
`user_id` BIGINT NOT NULL,
`updated_at` TIMESTAMP(6) NULL,
`status` TINYINT NOT NULL DEFAULT 1,

PRIMARY KEY (`id`)
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;

-- AddForeignKey
ALTER TABLE `user_group` ADD CONSTRAINT `user_group_userId_fkey` FOREIGN KEY (`userId`) REFERENCES `user`(`id`) ON DELETE CASCADE ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE `user_group` ADD CONSTRAINT `user_group_groupId_fkey` FOREIGN KEY (`groupId`) REFERENCES `group`(`id`) ON DELETE CASCADE ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE `todo` ADD CONSTRAINT `todo_user_id_fkey` FOREIGN KEY (`user_id`) REFERENCES `user`(`id`) ON DELETE CASCADE ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE `concentration` ADD CONSTRAINT `concentration_todo_id_fkey` FOREIGN KEY (`todo_id`) REFERENCES `todo`(`id`) ON DELETE CASCADE ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE `focus_target` ADD CONSTRAINT `focus_target_user_id_fkey` FOREIGN KEY (`user_id`) REFERENCES `user`(`id`) ON DELETE CASCADE ON UPDATE CASCADE;
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
/*
Warnings:

- You are about to drop the column `nickname` on the `user` table. All the data in the column will be lost.
- You are about to drop the `concentration` table. If the table is not empty, all the data it contains will be lost.

*/
-- DropForeignKey
ALTER TABLE `concentration` DROP FOREIGN KEY `concentration_todo_id_fkey`;

-- AlterTable
ALTER TABLE `user` DROP COLUMN `nickname`;

-- DropTable
DROP TABLE `concentration`;
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
/*
Warnings:

- You are about to drop the column `end_time` on the `focus_target` table. All the data in the column will be lost.
- You are about to drop the column `start_time` on the `focus_target` table. All the data in the column will be lost.
- You are about to drop the column `start_time` on the `todo` table. All the data in the column will be lost.
- Added the required column `description` to the `group` table without a default value. This is not possible if the table is not empty.
- Added the required column `description` to the `todo` table without a default value. This is not possible if the table is not empty.
- Made the column `end_time` on table `todo` required. This step will fail if there are existing NULL values in that column.

*/
-- AlterTable
ALTER TABLE `focus_target` DROP COLUMN `end_time`,
DROP COLUMN `start_time`,
ADD COLUMN `created_at` TIMESTAMP(6) NOT NULL DEFAULT CURRENT_TIMESTAMP(6);

-- AlterTable
ALTER TABLE `group` ADD COLUMN `description` VARCHAR(100) NOT NULL;

-- AlterTable
ALTER TABLE `todo` DROP COLUMN `start_time`,
ADD COLUMN `created_at` TIMESTAMP(6) NOT NULL DEFAULT CURRENT_TIMESTAMP(6),
ADD COLUMN `description` VARCHAR(100) NOT NULL,
ADD COLUMN `repeat_date` VARCHAR(6) NULL,
ADD COLUMN `start_date` DATETIME(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3),
ADD COLUMN `updated_at` TIMESTAMP(6) NULL,
MODIFY `end_time` DATETIME(3) NOT NULL;

-- CreateTable
CREATE TABLE `schedule` (
`id` BIGINT NOT NULL AUTO_INCREMENT,
`title` VARCHAR(50) NOT NULL,
`user_id` BIGINT NOT NULL,
`description` VARCHAR(100) NOT NULL,
`start_date` DATETIME(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3),
`end_date` DATETIME(3) NOT NULL,
`repeat_type` VARCHAR(6) NULL,
`created_at` TIMESTAMP(6) NOT NULL DEFAULT CURRENT_TIMESTAMP(6),
`updated_at` TIMESTAMP(6) NULL,
`status` TINYINT NOT NULL DEFAULT 1,

PRIMARY KEY (`id`)
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;

-- CreateTable
CREATE TABLE `time_table` (
`id` BIGINT NOT NULL AUTO_INCREMENT,
`measurement_start_at` DATETIME(3) NOT NULL,
`measurement_end_at` DATETIME(3) NOT NULL,
`todo_id` BIGINT NOT NULL,
`schedule_id` BIGINT NOT NULL,
`focus_target_id` BIGINT NOT NULL,
`created_at` TIMESTAMP(6) NOT NULL DEFAULT CURRENT_TIMESTAMP(6),
`updated_at` TIMESTAMP(6) NULL,
`status` TINYINT NOT NULL DEFAULT 1,

PRIMARY KEY (`id`)
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;

-- AddForeignKey
ALTER TABLE `schedule` ADD CONSTRAINT `schedule_user_id_fkey` FOREIGN KEY (`user_id`) REFERENCES `user`(`id`) ON DELETE CASCADE ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE `time_table` ADD CONSTRAINT `time_table_todo_id_fkey` FOREIGN KEY (`todo_id`) REFERENCES `todo`(`id`) ON DELETE CASCADE ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE `time_table` ADD CONSTRAINT `time_table_schedule_id_fkey` FOREIGN KEY (`schedule_id`) REFERENCES `schedule`(`id`) ON DELETE CASCADE ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE `time_table` ADD CONSTRAINT `time_table_focus_target_id_fkey` FOREIGN KEY (`focus_target_id`) REFERENCES `focus_target`(`id`) ON DELETE CASCADE ON UPDATE CASCADE;
23 changes: 23 additions & 0 deletions prisma/migrations/20250430154655_modify_detail/migration.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/*
Warnings:

- You are about to drop the column `repeat_date` on the `todo` table. All the data in the column will be lost.
- You are about to drop the column `user_group_id` on the `user` table. All the data in the column will be lost.

*/
-- AlterTable
ALTER TABLE `group` MODIFY `description` VARCHAR(100) NOT NULL DEFAULT '';

-- AlterTable
ALTER TABLE `time_table` MODIFY `todo_id` BIGINT NULL,
MODIFY `schedule_id` BIGINT NULL,
MODIFY `focus_target_id` BIGINT NULL;

-- AlterTable
ALTER TABLE `todo` DROP COLUMN `repeat_date`,
ADD COLUMN `repeat_type` VARCHAR(6) NULL,
MODIFY `is_completed` TINYINT NOT NULL DEFAULT 0,
MODIFY `description` VARCHAR(100) NOT NULL DEFAULT '';

-- AlterTable
ALTER TABLE `user` DROP COLUMN `user_group_id`;
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/*
Warnings:

- You are about to drop the column `todo_id` on the `time_table` table. All the data in the column will be lost.
- You are about to drop the `todo` table. If the table is not empty, all the data it contains will be lost.
- A unique constraint covering the columns `[hostId]` on the table `group` will be added. If there are existing duplicate values, this will fail.
- Added the required column `hostId` to the `group` table without a default value. This is not possible if the table is not empty.

*/
-- DropForeignKey
ALTER TABLE `time_table` DROP FOREIGN KEY `time_table_todo_id_fkey`;

-- DropForeignKey
ALTER TABLE `todo` DROP FOREIGN KEY `todo_user_id_fkey`;

-- DropIndex
DROP INDEX `time_table_todo_id_fkey` ON `time_table`;

-- AlterTable
ALTER TABLE `group` ADD COLUMN `hostId` BIGINT NOT NULL;

-- AlterTable
ALTER TABLE `schedule` ADD COLUMN `notification` TINYINT NOT NULL DEFAULT 0;

-- AlterTable
ALTER TABLE `time_table` DROP COLUMN `todo_id`;

-- DropTable
DROP TABLE `todo`;

-- CreateIndex
CREATE UNIQUE INDEX `host_id` ON `group`(`hostId`);
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
/*
Warnings:

- Made the column `repeat_type` on table `schedule` required. This step will fail if there are existing NULL values in that column.

*/
-- AlterTable
ALTER TABLE `schedule` MODIFY `description` VARCHAR(100) NULL,
MODIFY `repeat_type` VARCHAR(6) NOT NULL DEFAULT '반복 안함';
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
-- AlterTable
ALTER TABLE `group` MODIFY `description` VARCHAR(100) NULL DEFAULT '';
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
-- AlterTable
ALTER TABLE `schedule` ADD COLUMN `is_completed` TINYINT NOT NULL DEFAULT 0;
Loading