diff --git a/src/infrastructure/db.ts b/src/infrastructure/db.ts index 89c92ab..69b1f28 100644 --- a/src/infrastructure/db.ts +++ b/src/infrastructure/db.ts @@ -3,7 +3,7 @@ import ormconfig from '../ormconfig'; export async function startTypeORM() { const connection = await createConnection(ormconfig); - await connection.synchronize(true); + //await connection.synchronize(true); console.log('db 연결 성공'); } diff --git a/src/server/libs/application/user/user-repository.ts b/src/server/libs/application/user/user-repository.ts index 7a9758b..6fc9a19 100644 --- a/src/server/libs/application/user/user-repository.ts +++ b/src/server/libs/application/user/user-repository.ts @@ -12,7 +12,14 @@ class UserRepository extends Repository { const user = await User.createQueryBuilder().insert().into(User).values({ email,nickname,oauthProvider,oauthId}).execute(); return user.identifiers[0].id; } - + + async deleteUser(oauthId:string): Promise { + const user = await User.createQueryBuilder(). + delete().from(User). + where("oauthId = :oauthId", {oauthId:oauthId}).execute(); + + return ; + } } diff --git a/src/server/routes/users/deleteUser.ts b/src/server/routes/users/deleteUser.ts new file mode 100644 index 0000000..51edcd7 --- /dev/null +++ b/src/server/routes/users/deleteUser.ts @@ -0,0 +1,20 @@ +import {defineSchema} from '../../libs/schema'; +import {z} from 'zod'; +import {defineRoute} from '../../libs/route'; +import {getCustomRepository} from "typeorm"; +import UserRepository from "../../libs/application/user/user-repository"; + + +const schema = defineSchema({ + params: { + oauthId: z.string(), + }, +}); + +export default defineRoute('delete', '/user/:oauthId?', schema, async (req, res) => { + + const {oauthId} = req.params; + await getCustomRepository(UserRepository).deleteUser(oauthId); + + res.send(); +}); \ No newline at end of file