Skip to content

Commit

Permalink
wip: create sign-up-with-email route
Browse files Browse the repository at this point in the history
  • Loading branch information
clintonbrito committed Aug 20, 2024
1 parent 8f17986 commit 6e6a1dd
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 5 deletions.
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
import type { UserWithEmailModel } from '@/models/user-with-email-model'
import type { SignUpWithEmailRepo } from '@/usecases/contracts/db/user/sign-up-with-email-repo'
import { PrismaHelper } from '../../../helpers'
import { UuidAdapter } from '@/infra/uuid-adapter/uuid-adapter'

export class SignUpWithEmailPrismaRepo implements SignUpWithEmailRepo {
async execute (data: UserWithEmailModel): Promise<void> {
const id = new UuidAdapter().build()
const prisma = await PrismaHelper.getPrisma()
await prisma.userWithEmail.create({ data }) // TODO: create a userWithEmail model in prisma
const userData = { ...data, id }
await prisma.userWithEmail.create({ data: userData })
}
}
3 changes: 2 additions & 1 deletion src/infra/database/prisma/schema/schema.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,8 @@ enum Frequency {
}

model UserWithEmail {
id String @id(map: "pk_user_with_email") @unique(map: "uq_user_with_email_id") @db.VarChar(50)
// id String @id(map: "pk_user_with_email") @unique(map: "uq_user_with_email_id") @db.Uuid()
id String @id @default(uuid()) @db.VarChar(36)
email String @unique(map: "uq_user_with_email_email") @db.VarChar(256)
password String @db.VarChar(100)
Expand Down
6 changes: 3 additions & 3 deletions src/routes/user/user-routes.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ export class UserRoutesModule implements NestModule {
configure (consumer: MiddlewareConsumer): void {
consumer
.apply(AuthNestMiddleware)
.forRoutes(
{ path: '/user', method: RequestMethod.POST }
)
.forRoutes({ path: '/user/signup/email', method: RequestMethod.POST })
.apply(AuthNestMiddleware)
.forRoutes({ path: '/user', method: RequestMethod.POST })
.apply(WebhookValidatorNestMiddleware)
.forRoutes({ path: '/user/signup/webhook', method: RequestMethod.POST })
}
Expand Down

0 comments on commit 6e6a1dd

Please sign in to comment.