Repo act
This commit is contained in:
parent
fea50d5064
commit
5538b7340d
14 changed files with 306 additions and 102 deletions
15
backend/.dockerignore
Normal file
15
backend/.dockerignore
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
node_modules
|
||||
npm-debug.log
|
||||
dist
|
||||
.git
|
||||
.gitignore
|
||||
README.md
|
||||
.env
|
||||
.env.local
|
||||
.env.*.local
|
||||
.vscode
|
||||
.idea
|
||||
*.swp
|
||||
*.swo
|
||||
*~
|
||||
.DS_Store
|
||||
15
backend/.env.example
Normal file
15
backend/.env.example
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
# Database
|
||||
DATABASE_URL=postgresql://user:password@localhost:5432/toptran
|
||||
DB_USER=user
|
||||
DB_PASSWORD=password
|
||||
DB_HOST=localhost
|
||||
DB_PORT=5432
|
||||
DB_NAME=toptran
|
||||
|
||||
# Server
|
||||
PORT=4000
|
||||
NODE_ENV=production
|
||||
|
||||
# JWT
|
||||
JWT_SECRET=sua_chave_secreta_aqui
|
||||
JWT_REFRESH_SECRET=sua_chave_refresh_aqui
|
||||
|
|
@ -1,13 +1,30 @@
|
|||
FROM node:lts-alpine3.22
|
||||
# Build stage
|
||||
FROM node:lts-alpine3.22 AS builder
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
COPY package*.json ./
|
||||
|
||||
RUN npm install
|
||||
RUN npm ci --only=production
|
||||
|
||||
COPY . .
|
||||
|
||||
EXPOSE 3000
|
||||
RUN npm run build
|
||||
|
||||
# Runtime stage
|
||||
FROM node:lts-alpine3.22
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
# Copiar apenas arquivos necessários do builder
|
||||
COPY --from=builder /app/dist ./dist
|
||||
COPY --from=builder /app/node_modules ./node_modules
|
||||
COPY --from=builder /app/prisma ./prisma
|
||||
COPY --from=builder /app/package*.json ./
|
||||
|
||||
ENV NODE_ENV=production
|
||||
ENV PORT=4000
|
||||
|
||||
EXPOSE 4000
|
||||
|
||||
CMD ["npm", "start"]
|
||||
|
|
@ -18,14 +18,18 @@ model tokens {
|
|||
}
|
||||
|
||||
model users {
|
||||
id String @id
|
||||
name String
|
||||
email String @unique
|
||||
password String
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime
|
||||
rides rides[]
|
||||
tokens tokens[]
|
||||
id String @id
|
||||
name String
|
||||
email String @unique
|
||||
password String
|
||||
profilePhoto String? @default("")
|
||||
bio String? @default("")
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime
|
||||
rides rides[]
|
||||
tokens tokens[]
|
||||
|
||||
@@index([email], map: "idx_users_email")
|
||||
}
|
||||
|
||||
model companies {
|
||||
|
|
|
|||
|
|
@ -11,6 +11,15 @@ export async function get(req: AuthRequest, res: Response): Promise<void> {
|
|||
}
|
||||
}
|
||||
|
||||
export async function getProfile(req: AuthRequest, res: Response): Promise<void> {
|
||||
try {
|
||||
const profile = await usersService.getProfile(req.userId!);
|
||||
res.json(profile);
|
||||
} catch (err: any) {
|
||||
res.status(404).json({ error: err.message });
|
||||
}
|
||||
}
|
||||
|
||||
export async function update(req: AuthRequest, res: Response): Promise<void> {
|
||||
const parsed = usersService.updateUserSchema.safeParse(req.body);
|
||||
if (!parsed.success) {
|
||||
|
|
@ -26,8 +35,22 @@ export async function update(req: AuthRequest, res: Response): Promise<void> {
|
|||
}
|
||||
}
|
||||
|
||||
export async function remove(req: AuthRequest, res: Response): Promise<void> {
|
||||
export async function updateProfile(req: AuthRequest, res: Response): Promise<void> {
|
||||
const parsed = usersService.updateProfileSchema.safeParse(req.body);
|
||||
if (!parsed.success) {
|
||||
res.status(400).json({ error: parsed.error.flatten() });
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
const profile = await usersService.updateProfile(req.userId!, parsed.data);
|
||||
res.json(profile);
|
||||
} catch (err: any) {
|
||||
res.status(400).json({ error: err.message });
|
||||
}
|
||||
}
|
||||
|
||||
export async function remove(req: AuthRequest, res: Response): Promise<void> {
|
||||
try {
|
||||
await usersService.deleteUser(req.userId!);
|
||||
res.status(204).send();
|
||||
|
|
|
|||
|
|
@ -89,17 +89,6 @@ export type DateTimeWithAggregatesFilter<$PrismaModel = never> = {
|
|||
_max?: Prisma.NestedDateTimeFilter<$PrismaModel>
|
||||
}
|
||||
|
||||
export type DecimalFilter<$PrismaModel = never> = {
|
||||
equals?: runtime.Decimal | runtime.DecimalJsLike | number | string | Prisma.DecimalFieldRefInput<$PrismaModel>
|
||||
in?: runtime.Decimal[] | runtime.DecimalJsLike[] | number[] | string[] | Prisma.ListDecimalFieldRefInput<$PrismaModel>
|
||||
notIn?: runtime.Decimal[] | runtime.DecimalJsLike[] | number[] | string[] | Prisma.ListDecimalFieldRefInput<$PrismaModel>
|
||||
lt?: runtime.Decimal | runtime.DecimalJsLike | number | string | Prisma.DecimalFieldRefInput<$PrismaModel>
|
||||
lte?: runtime.Decimal | runtime.DecimalJsLike | number | string | Prisma.DecimalFieldRefInput<$PrismaModel>
|
||||
gt?: runtime.Decimal | runtime.DecimalJsLike | number | string | Prisma.DecimalFieldRefInput<$PrismaModel>
|
||||
gte?: runtime.Decimal | runtime.DecimalJsLike | number | string | Prisma.DecimalFieldRefInput<$PrismaModel>
|
||||
not?: Prisma.NestedDecimalFilter<$PrismaModel> | runtime.Decimal | runtime.DecimalJsLike | number | string
|
||||
}
|
||||
|
||||
export type StringNullableFilter<$PrismaModel = never> = {
|
||||
equals?: string | Prisma.StringFieldRefInput<$PrismaModel> | null
|
||||
in?: string[] | Prisma.ListStringFieldRefInput<$PrismaModel> | null
|
||||
|
|
@ -115,38 +104,11 @@ export type StringNullableFilter<$PrismaModel = never> = {
|
|||
not?: Prisma.NestedStringNullableFilter<$PrismaModel> | string | null
|
||||
}
|
||||
|
||||
export type DateTimeNullableFilter<$PrismaModel = never> = {
|
||||
equals?: Date | string | Prisma.DateTimeFieldRefInput<$PrismaModel> | null
|
||||
in?: Date[] | string[] | Prisma.ListDateTimeFieldRefInput<$PrismaModel> | null
|
||||
notIn?: Date[] | string[] | Prisma.ListDateTimeFieldRefInput<$PrismaModel> | null
|
||||
lt?: Date | string | Prisma.DateTimeFieldRefInput<$PrismaModel>
|
||||
lte?: Date | string | Prisma.DateTimeFieldRefInput<$PrismaModel>
|
||||
gt?: Date | string | Prisma.DateTimeFieldRefInput<$PrismaModel>
|
||||
gte?: Date | string | Prisma.DateTimeFieldRefInput<$PrismaModel>
|
||||
not?: Prisma.NestedDateTimeNullableFilter<$PrismaModel> | Date | string | null
|
||||
}
|
||||
|
||||
export type SortOrderInput = {
|
||||
sort: Prisma.SortOrder
|
||||
nulls?: Prisma.NullsOrder
|
||||
}
|
||||
|
||||
export type DecimalWithAggregatesFilter<$PrismaModel = never> = {
|
||||
equals?: runtime.Decimal | runtime.DecimalJsLike | number | string | Prisma.DecimalFieldRefInput<$PrismaModel>
|
||||
in?: runtime.Decimal[] | runtime.DecimalJsLike[] | number[] | string[] | Prisma.ListDecimalFieldRefInput<$PrismaModel>
|
||||
notIn?: runtime.Decimal[] | runtime.DecimalJsLike[] | number[] | string[] | Prisma.ListDecimalFieldRefInput<$PrismaModel>
|
||||
lt?: runtime.Decimal | runtime.DecimalJsLike | number | string | Prisma.DecimalFieldRefInput<$PrismaModel>
|
||||
lte?: runtime.Decimal | runtime.DecimalJsLike | number | string | Prisma.DecimalFieldRefInput<$PrismaModel>
|
||||
gt?: runtime.Decimal | runtime.DecimalJsLike | number | string | Prisma.DecimalFieldRefInput<$PrismaModel>
|
||||
gte?: runtime.Decimal | runtime.DecimalJsLike | number | string | Prisma.DecimalFieldRefInput<$PrismaModel>
|
||||
not?: Prisma.NestedDecimalWithAggregatesFilter<$PrismaModel> | runtime.Decimal | runtime.DecimalJsLike | number | string
|
||||
_count?: Prisma.NestedIntFilter<$PrismaModel>
|
||||
_avg?: Prisma.NestedDecimalFilter<$PrismaModel>
|
||||
_sum?: Prisma.NestedDecimalFilter<$PrismaModel>
|
||||
_min?: Prisma.NestedDecimalFilter<$PrismaModel>
|
||||
_max?: Prisma.NestedDecimalFilter<$PrismaModel>
|
||||
}
|
||||
|
||||
export type StringNullableWithAggregatesFilter<$PrismaModel = never> = {
|
||||
equals?: string | Prisma.StringFieldRefInput<$PrismaModel> | null
|
||||
in?: string[] | Prisma.ListStringFieldRefInput<$PrismaModel> | null
|
||||
|
|
@ -165,6 +127,44 @@ export type StringNullableWithAggregatesFilter<$PrismaModel = never> = {
|
|||
_max?: Prisma.NestedStringNullableFilter<$PrismaModel>
|
||||
}
|
||||
|
||||
export type DecimalFilter<$PrismaModel = never> = {
|
||||
equals?: runtime.Decimal | runtime.DecimalJsLike | number | string | Prisma.DecimalFieldRefInput<$PrismaModel>
|
||||
in?: runtime.Decimal[] | runtime.DecimalJsLike[] | number[] | string[] | Prisma.ListDecimalFieldRefInput<$PrismaModel>
|
||||
notIn?: runtime.Decimal[] | runtime.DecimalJsLike[] | number[] | string[] | Prisma.ListDecimalFieldRefInput<$PrismaModel>
|
||||
lt?: runtime.Decimal | runtime.DecimalJsLike | number | string | Prisma.DecimalFieldRefInput<$PrismaModel>
|
||||
lte?: runtime.Decimal | runtime.DecimalJsLike | number | string | Prisma.DecimalFieldRefInput<$PrismaModel>
|
||||
gt?: runtime.Decimal | runtime.DecimalJsLike | number | string | Prisma.DecimalFieldRefInput<$PrismaModel>
|
||||
gte?: runtime.Decimal | runtime.DecimalJsLike | number | string | Prisma.DecimalFieldRefInput<$PrismaModel>
|
||||
not?: Prisma.NestedDecimalFilter<$PrismaModel> | runtime.Decimal | runtime.DecimalJsLike | number | string
|
||||
}
|
||||
|
||||
export type DateTimeNullableFilter<$PrismaModel = never> = {
|
||||
equals?: Date | string | Prisma.DateTimeFieldRefInput<$PrismaModel> | null
|
||||
in?: Date[] | string[] | Prisma.ListDateTimeFieldRefInput<$PrismaModel> | null
|
||||
notIn?: Date[] | string[] | Prisma.ListDateTimeFieldRefInput<$PrismaModel> | null
|
||||
lt?: Date | string | Prisma.DateTimeFieldRefInput<$PrismaModel>
|
||||
lte?: Date | string | Prisma.DateTimeFieldRefInput<$PrismaModel>
|
||||
gt?: Date | string | Prisma.DateTimeFieldRefInput<$PrismaModel>
|
||||
gte?: Date | string | Prisma.DateTimeFieldRefInput<$PrismaModel>
|
||||
not?: Prisma.NestedDateTimeNullableFilter<$PrismaModel> | Date | string | null
|
||||
}
|
||||
|
||||
export type DecimalWithAggregatesFilter<$PrismaModel = never> = {
|
||||
equals?: runtime.Decimal | runtime.DecimalJsLike | number | string | Prisma.DecimalFieldRefInput<$PrismaModel>
|
||||
in?: runtime.Decimal[] | runtime.DecimalJsLike[] | number[] | string[] | Prisma.ListDecimalFieldRefInput<$PrismaModel>
|
||||
notIn?: runtime.Decimal[] | runtime.DecimalJsLike[] | number[] | string[] | Prisma.ListDecimalFieldRefInput<$PrismaModel>
|
||||
lt?: runtime.Decimal | runtime.DecimalJsLike | number | string | Prisma.DecimalFieldRefInput<$PrismaModel>
|
||||
lte?: runtime.Decimal | runtime.DecimalJsLike | number | string | Prisma.DecimalFieldRefInput<$PrismaModel>
|
||||
gt?: runtime.Decimal | runtime.DecimalJsLike | number | string | Prisma.DecimalFieldRefInput<$PrismaModel>
|
||||
gte?: runtime.Decimal | runtime.DecimalJsLike | number | string | Prisma.DecimalFieldRefInput<$PrismaModel>
|
||||
not?: Prisma.NestedDecimalWithAggregatesFilter<$PrismaModel> | runtime.Decimal | runtime.DecimalJsLike | number | string
|
||||
_count?: Prisma.NestedIntFilter<$PrismaModel>
|
||||
_avg?: Prisma.NestedDecimalFilter<$PrismaModel>
|
||||
_sum?: Prisma.NestedDecimalFilter<$PrismaModel>
|
||||
_min?: Prisma.NestedDecimalFilter<$PrismaModel>
|
||||
_max?: Prisma.NestedDecimalFilter<$PrismaModel>
|
||||
}
|
||||
|
||||
export type DateTimeNullableWithAggregatesFilter<$PrismaModel = never> = {
|
||||
equals?: Date | string | Prisma.DateTimeFieldRefInput<$PrismaModel> | null
|
||||
in?: Date[] | string[] | Prisma.ListDateTimeFieldRefInput<$PrismaModel> | null
|
||||
|
|
@ -290,17 +290,6 @@ export type NestedDateTimeWithAggregatesFilter<$PrismaModel = never> = {
|
|||
_max?: Prisma.NestedDateTimeFilter<$PrismaModel>
|
||||
}
|
||||
|
||||
export type NestedDecimalFilter<$PrismaModel = never> = {
|
||||
equals?: runtime.Decimal | runtime.DecimalJsLike | number | string | Prisma.DecimalFieldRefInput<$PrismaModel>
|
||||
in?: runtime.Decimal[] | runtime.DecimalJsLike[] | number[] | string[] | Prisma.ListDecimalFieldRefInput<$PrismaModel>
|
||||
notIn?: runtime.Decimal[] | runtime.DecimalJsLike[] | number[] | string[] | Prisma.ListDecimalFieldRefInput<$PrismaModel>
|
||||
lt?: runtime.Decimal | runtime.DecimalJsLike | number | string | Prisma.DecimalFieldRefInput<$PrismaModel>
|
||||
lte?: runtime.Decimal | runtime.DecimalJsLike | number | string | Prisma.DecimalFieldRefInput<$PrismaModel>
|
||||
gt?: runtime.Decimal | runtime.DecimalJsLike | number | string | Prisma.DecimalFieldRefInput<$PrismaModel>
|
||||
gte?: runtime.Decimal | runtime.DecimalJsLike | number | string | Prisma.DecimalFieldRefInput<$PrismaModel>
|
||||
not?: Prisma.NestedDecimalFilter<$PrismaModel> | runtime.Decimal | runtime.DecimalJsLike | number | string
|
||||
}
|
||||
|
||||
export type NestedStringNullableFilter<$PrismaModel = never> = {
|
||||
equals?: string | Prisma.StringFieldRefInput<$PrismaModel> | null
|
||||
in?: string[] | Prisma.ListStringFieldRefInput<$PrismaModel> | null
|
||||
|
|
@ -315,33 +304,6 @@ export type NestedStringNullableFilter<$PrismaModel = never> = {
|
|||
not?: Prisma.NestedStringNullableFilter<$PrismaModel> | string | null
|
||||
}
|
||||
|
||||
export type NestedDateTimeNullableFilter<$PrismaModel = never> = {
|
||||
equals?: Date | string | Prisma.DateTimeFieldRefInput<$PrismaModel> | null
|
||||
in?: Date[] | string[] | Prisma.ListDateTimeFieldRefInput<$PrismaModel> | null
|
||||
notIn?: Date[] | string[] | Prisma.ListDateTimeFieldRefInput<$PrismaModel> | null
|
||||
lt?: Date | string | Prisma.DateTimeFieldRefInput<$PrismaModel>
|
||||
lte?: Date | string | Prisma.DateTimeFieldRefInput<$PrismaModel>
|
||||
gt?: Date | string | Prisma.DateTimeFieldRefInput<$PrismaModel>
|
||||
gte?: Date | string | Prisma.DateTimeFieldRefInput<$PrismaModel>
|
||||
not?: Prisma.NestedDateTimeNullableFilter<$PrismaModel> | Date | string | null
|
||||
}
|
||||
|
||||
export type NestedDecimalWithAggregatesFilter<$PrismaModel = never> = {
|
||||
equals?: runtime.Decimal | runtime.DecimalJsLike | number | string | Prisma.DecimalFieldRefInput<$PrismaModel>
|
||||
in?: runtime.Decimal[] | runtime.DecimalJsLike[] | number[] | string[] | Prisma.ListDecimalFieldRefInput<$PrismaModel>
|
||||
notIn?: runtime.Decimal[] | runtime.DecimalJsLike[] | number[] | string[] | Prisma.ListDecimalFieldRefInput<$PrismaModel>
|
||||
lt?: runtime.Decimal | runtime.DecimalJsLike | number | string | Prisma.DecimalFieldRefInput<$PrismaModel>
|
||||
lte?: runtime.Decimal | runtime.DecimalJsLike | number | string | Prisma.DecimalFieldRefInput<$PrismaModel>
|
||||
gt?: runtime.Decimal | runtime.DecimalJsLike | number | string | Prisma.DecimalFieldRefInput<$PrismaModel>
|
||||
gte?: runtime.Decimal | runtime.DecimalJsLike | number | string | Prisma.DecimalFieldRefInput<$PrismaModel>
|
||||
not?: Prisma.NestedDecimalWithAggregatesFilter<$PrismaModel> | runtime.Decimal | runtime.DecimalJsLike | number | string
|
||||
_count?: Prisma.NestedIntFilter<$PrismaModel>
|
||||
_avg?: Prisma.NestedDecimalFilter<$PrismaModel>
|
||||
_sum?: Prisma.NestedDecimalFilter<$PrismaModel>
|
||||
_min?: Prisma.NestedDecimalFilter<$PrismaModel>
|
||||
_max?: Prisma.NestedDecimalFilter<$PrismaModel>
|
||||
}
|
||||
|
||||
export type NestedStringNullableWithAggregatesFilter<$PrismaModel = never> = {
|
||||
equals?: string | Prisma.StringFieldRefInput<$PrismaModel> | null
|
||||
in?: string[] | Prisma.ListStringFieldRefInput<$PrismaModel> | null
|
||||
|
|
@ -370,6 +332,44 @@ export type NestedIntNullableFilter<$PrismaModel = never> = {
|
|||
not?: Prisma.NestedIntNullableFilter<$PrismaModel> | number | null
|
||||
}
|
||||
|
||||
export type NestedDecimalFilter<$PrismaModel = never> = {
|
||||
equals?: runtime.Decimal | runtime.DecimalJsLike | number | string | Prisma.DecimalFieldRefInput<$PrismaModel>
|
||||
in?: runtime.Decimal[] | runtime.DecimalJsLike[] | number[] | string[] | Prisma.ListDecimalFieldRefInput<$PrismaModel>
|
||||
notIn?: runtime.Decimal[] | runtime.DecimalJsLike[] | number[] | string[] | Prisma.ListDecimalFieldRefInput<$PrismaModel>
|
||||
lt?: runtime.Decimal | runtime.DecimalJsLike | number | string | Prisma.DecimalFieldRefInput<$PrismaModel>
|
||||
lte?: runtime.Decimal | runtime.DecimalJsLike | number | string | Prisma.DecimalFieldRefInput<$PrismaModel>
|
||||
gt?: runtime.Decimal | runtime.DecimalJsLike | number | string | Prisma.DecimalFieldRefInput<$PrismaModel>
|
||||
gte?: runtime.Decimal | runtime.DecimalJsLike | number | string | Prisma.DecimalFieldRefInput<$PrismaModel>
|
||||
not?: Prisma.NestedDecimalFilter<$PrismaModel> | runtime.Decimal | runtime.DecimalJsLike | number | string
|
||||
}
|
||||
|
||||
export type NestedDateTimeNullableFilter<$PrismaModel = never> = {
|
||||
equals?: Date | string | Prisma.DateTimeFieldRefInput<$PrismaModel> | null
|
||||
in?: Date[] | string[] | Prisma.ListDateTimeFieldRefInput<$PrismaModel> | null
|
||||
notIn?: Date[] | string[] | Prisma.ListDateTimeFieldRefInput<$PrismaModel> | null
|
||||
lt?: Date | string | Prisma.DateTimeFieldRefInput<$PrismaModel>
|
||||
lte?: Date | string | Prisma.DateTimeFieldRefInput<$PrismaModel>
|
||||
gt?: Date | string | Prisma.DateTimeFieldRefInput<$PrismaModel>
|
||||
gte?: Date | string | Prisma.DateTimeFieldRefInput<$PrismaModel>
|
||||
not?: Prisma.NestedDateTimeNullableFilter<$PrismaModel> | Date | string | null
|
||||
}
|
||||
|
||||
export type NestedDecimalWithAggregatesFilter<$PrismaModel = never> = {
|
||||
equals?: runtime.Decimal | runtime.DecimalJsLike | number | string | Prisma.DecimalFieldRefInput<$PrismaModel>
|
||||
in?: runtime.Decimal[] | runtime.DecimalJsLike[] | number[] | string[] | Prisma.ListDecimalFieldRefInput<$PrismaModel>
|
||||
notIn?: runtime.Decimal[] | runtime.DecimalJsLike[] | number[] | string[] | Prisma.ListDecimalFieldRefInput<$PrismaModel>
|
||||
lt?: runtime.Decimal | runtime.DecimalJsLike | number | string | Prisma.DecimalFieldRefInput<$PrismaModel>
|
||||
lte?: runtime.Decimal | runtime.DecimalJsLike | number | string | Prisma.DecimalFieldRefInput<$PrismaModel>
|
||||
gt?: runtime.Decimal | runtime.DecimalJsLike | number | string | Prisma.DecimalFieldRefInput<$PrismaModel>
|
||||
gte?: runtime.Decimal | runtime.DecimalJsLike | number | string | Prisma.DecimalFieldRefInput<$PrismaModel>
|
||||
not?: Prisma.NestedDecimalWithAggregatesFilter<$PrismaModel> | runtime.Decimal | runtime.DecimalJsLike | number | string
|
||||
_count?: Prisma.NestedIntFilter<$PrismaModel>
|
||||
_avg?: Prisma.NestedDecimalFilter<$PrismaModel>
|
||||
_sum?: Prisma.NestedDecimalFilter<$PrismaModel>
|
||||
_min?: Prisma.NestedDecimalFilter<$PrismaModel>
|
||||
_max?: Prisma.NestedDecimalFilter<$PrismaModel>
|
||||
}
|
||||
|
||||
export type NestedDateTimeNullableWithAggregatesFilter<$PrismaModel = never> = {
|
||||
equals?: Date | string | Prisma.DateTimeFieldRefInput<$PrismaModel> | null
|
||||
in?: Date[] | string[] | Prisma.ListDateTimeFieldRefInput<$PrismaModel> | null
|
||||
|
|
|
|||
File diff suppressed because one or more lines are too long
|
|
@ -759,6 +759,8 @@ export const UsersScalarFieldEnum = {
|
|||
name: 'name',
|
||||
email: 'email',
|
||||
password: 'password',
|
||||
profilePhoto: 'profilePhoto',
|
||||
bio: 'bio',
|
||||
createdAt: 'createdAt',
|
||||
updatedAt: 'updatedAt'
|
||||
} as const
|
||||
|
|
|
|||
|
|
@ -90,6 +90,8 @@ export const UsersScalarFieldEnum = {
|
|||
name: 'name',
|
||||
email: 'email',
|
||||
password: 'password',
|
||||
profilePhoto: 'profilePhoto',
|
||||
bio: 'bio',
|
||||
createdAt: 'createdAt',
|
||||
updatedAt: 'updatedAt'
|
||||
} as const
|
||||
|
|
|
|||
|
|
@ -379,10 +379,6 @@ export type DecimalFieldUpdateOperationsInput = {
|
|||
divide?: runtime.Decimal | runtime.DecimalJsLike | number | string
|
||||
}
|
||||
|
||||
export type NullableStringFieldUpdateOperationsInput = {
|
||||
set?: string | null
|
||||
}
|
||||
|
||||
export type NullableDateTimeFieldUpdateOperationsInput = {
|
||||
set?: Date | string | null
|
||||
}
|
||||
|
|
|
|||
|
|
@ -29,6 +29,8 @@ export type UsersMinAggregateOutputType = {
|
|||
name: string | null
|
||||
email: string | null
|
||||
password: string | null
|
||||
profilePhoto: string | null
|
||||
bio: string | null
|
||||
createdAt: Date | null
|
||||
updatedAt: Date | null
|
||||
}
|
||||
|
|
@ -38,6 +40,8 @@ export type UsersMaxAggregateOutputType = {
|
|||
name: string | null
|
||||
email: string | null
|
||||
password: string | null
|
||||
profilePhoto: string | null
|
||||
bio: string | null
|
||||
createdAt: Date | null
|
||||
updatedAt: Date | null
|
||||
}
|
||||
|
|
@ -47,6 +51,8 @@ export type UsersCountAggregateOutputType = {
|
|||
name: number
|
||||
email: number
|
||||
password: number
|
||||
profilePhoto: number
|
||||
bio: number
|
||||
createdAt: number
|
||||
updatedAt: number
|
||||
_all: number
|
||||
|
|
@ -58,6 +64,8 @@ export type UsersMinAggregateInputType = {
|
|||
name?: true
|
||||
email?: true
|
||||
password?: true
|
||||
profilePhoto?: true
|
||||
bio?: true
|
||||
createdAt?: true
|
||||
updatedAt?: true
|
||||
}
|
||||
|
|
@ -67,6 +75,8 @@ export type UsersMaxAggregateInputType = {
|
|||
name?: true
|
||||
email?: true
|
||||
password?: true
|
||||
profilePhoto?: true
|
||||
bio?: true
|
||||
createdAt?: true
|
||||
updatedAt?: true
|
||||
}
|
||||
|
|
@ -76,6 +86,8 @@ export type UsersCountAggregateInputType = {
|
|||
name?: true
|
||||
email?: true
|
||||
password?: true
|
||||
profilePhoto?: true
|
||||
bio?: true
|
||||
createdAt?: true
|
||||
updatedAt?: true
|
||||
_all?: true
|
||||
|
|
@ -158,6 +170,8 @@ export type UsersGroupByOutputType = {
|
|||
name: string
|
||||
email: string
|
||||
password: string
|
||||
profilePhoto: string | null
|
||||
bio: string | null
|
||||
createdAt: Date
|
||||
updatedAt: Date
|
||||
_count: UsersCountAggregateOutputType | null
|
||||
|
|
@ -188,6 +202,8 @@ export type usersWhereInput = {
|
|||
name?: Prisma.StringFilter<"users"> | string
|
||||
email?: Prisma.StringFilter<"users"> | string
|
||||
password?: Prisma.StringFilter<"users"> | string
|
||||
profilePhoto?: Prisma.StringNullableFilter<"users"> | string | null
|
||||
bio?: Prisma.StringNullableFilter<"users"> | string | null
|
||||
createdAt?: Prisma.DateTimeFilter<"users"> | Date | string
|
||||
updatedAt?: Prisma.DateTimeFilter<"users"> | Date | string
|
||||
rides?: Prisma.RidesListRelationFilter
|
||||
|
|
@ -199,6 +215,8 @@ export type usersOrderByWithRelationInput = {
|
|||
name?: Prisma.SortOrder
|
||||
email?: Prisma.SortOrder
|
||||
password?: Prisma.SortOrder
|
||||
profilePhoto?: Prisma.SortOrderInput | Prisma.SortOrder
|
||||
bio?: Prisma.SortOrderInput | Prisma.SortOrder
|
||||
createdAt?: Prisma.SortOrder
|
||||
updatedAt?: Prisma.SortOrder
|
||||
rides?: Prisma.ridesOrderByRelationAggregateInput
|
||||
|
|
@ -213,6 +231,8 @@ export type usersWhereUniqueInput = Prisma.AtLeast<{
|
|||
NOT?: Prisma.usersWhereInput | Prisma.usersWhereInput[]
|
||||
name?: Prisma.StringFilter<"users"> | string
|
||||
password?: Prisma.StringFilter<"users"> | string
|
||||
profilePhoto?: Prisma.StringNullableFilter<"users"> | string | null
|
||||
bio?: Prisma.StringNullableFilter<"users"> | string | null
|
||||
createdAt?: Prisma.DateTimeFilter<"users"> | Date | string
|
||||
updatedAt?: Prisma.DateTimeFilter<"users"> | Date | string
|
||||
rides?: Prisma.RidesListRelationFilter
|
||||
|
|
@ -224,6 +244,8 @@ export type usersOrderByWithAggregationInput = {
|
|||
name?: Prisma.SortOrder
|
||||
email?: Prisma.SortOrder
|
||||
password?: Prisma.SortOrder
|
||||
profilePhoto?: Prisma.SortOrderInput | Prisma.SortOrder
|
||||
bio?: Prisma.SortOrderInput | Prisma.SortOrder
|
||||
createdAt?: Prisma.SortOrder
|
||||
updatedAt?: Prisma.SortOrder
|
||||
_count?: Prisma.usersCountOrderByAggregateInput
|
||||
|
|
@ -239,6 +261,8 @@ export type usersScalarWhereWithAggregatesInput = {
|
|||
name?: Prisma.StringWithAggregatesFilter<"users"> | string
|
||||
email?: Prisma.StringWithAggregatesFilter<"users"> | string
|
||||
password?: Prisma.StringWithAggregatesFilter<"users"> | string
|
||||
profilePhoto?: Prisma.StringNullableWithAggregatesFilter<"users"> | string | null
|
||||
bio?: Prisma.StringNullableWithAggregatesFilter<"users"> | string | null
|
||||
createdAt?: Prisma.DateTimeWithAggregatesFilter<"users"> | Date | string
|
||||
updatedAt?: Prisma.DateTimeWithAggregatesFilter<"users"> | Date | string
|
||||
}
|
||||
|
|
@ -248,6 +272,8 @@ export type usersCreateInput = {
|
|||
name: string
|
||||
email: string
|
||||
password: string
|
||||
profilePhoto?: string | null
|
||||
bio?: string | null
|
||||
createdAt?: Date | string
|
||||
updatedAt: Date | string
|
||||
rides?: Prisma.ridesCreateNestedManyWithoutUsersInput
|
||||
|
|
@ -259,6 +285,8 @@ export type usersUncheckedCreateInput = {
|
|||
name: string
|
||||
email: string
|
||||
password: string
|
||||
profilePhoto?: string | null
|
||||
bio?: string | null
|
||||
createdAt?: Date | string
|
||||
updatedAt: Date | string
|
||||
rides?: Prisma.ridesUncheckedCreateNestedManyWithoutUsersInput
|
||||
|
|
@ -270,6 +298,8 @@ export type usersUpdateInput = {
|
|||
name?: Prisma.StringFieldUpdateOperationsInput | string
|
||||
email?: Prisma.StringFieldUpdateOperationsInput | string
|
||||
password?: Prisma.StringFieldUpdateOperationsInput | string
|
||||
profilePhoto?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
|
||||
bio?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
|
||||
createdAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string
|
||||
updatedAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string
|
||||
rides?: Prisma.ridesUpdateManyWithoutUsersNestedInput
|
||||
|
|
@ -281,6 +311,8 @@ export type usersUncheckedUpdateInput = {
|
|||
name?: Prisma.StringFieldUpdateOperationsInput | string
|
||||
email?: Prisma.StringFieldUpdateOperationsInput | string
|
||||
password?: Prisma.StringFieldUpdateOperationsInput | string
|
||||
profilePhoto?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
|
||||
bio?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
|
||||
createdAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string
|
||||
updatedAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string
|
||||
rides?: Prisma.ridesUncheckedUpdateManyWithoutUsersNestedInput
|
||||
|
|
@ -292,6 +324,8 @@ export type usersCreateManyInput = {
|
|||
name: string
|
||||
email: string
|
||||
password: string
|
||||
profilePhoto?: string | null
|
||||
bio?: string | null
|
||||
createdAt?: Date | string
|
||||
updatedAt: Date | string
|
||||
}
|
||||
|
|
@ -301,6 +335,8 @@ export type usersUpdateManyMutationInput = {
|
|||
name?: Prisma.StringFieldUpdateOperationsInput | string
|
||||
email?: Prisma.StringFieldUpdateOperationsInput | string
|
||||
password?: Prisma.StringFieldUpdateOperationsInput | string
|
||||
profilePhoto?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
|
||||
bio?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
|
||||
createdAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string
|
||||
updatedAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string
|
||||
}
|
||||
|
|
@ -310,6 +346,8 @@ export type usersUncheckedUpdateManyInput = {
|
|||
name?: Prisma.StringFieldUpdateOperationsInput | string
|
||||
email?: Prisma.StringFieldUpdateOperationsInput | string
|
||||
password?: Prisma.StringFieldUpdateOperationsInput | string
|
||||
profilePhoto?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
|
||||
bio?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
|
||||
createdAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string
|
||||
updatedAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string
|
||||
}
|
||||
|
|
@ -324,6 +362,8 @@ export type usersCountOrderByAggregateInput = {
|
|||
name?: Prisma.SortOrder
|
||||
email?: Prisma.SortOrder
|
||||
password?: Prisma.SortOrder
|
||||
profilePhoto?: Prisma.SortOrder
|
||||
bio?: Prisma.SortOrder
|
||||
createdAt?: Prisma.SortOrder
|
||||
updatedAt?: Prisma.SortOrder
|
||||
}
|
||||
|
|
@ -333,6 +373,8 @@ export type usersMaxOrderByAggregateInput = {
|
|||
name?: Prisma.SortOrder
|
||||
email?: Prisma.SortOrder
|
||||
password?: Prisma.SortOrder
|
||||
profilePhoto?: Prisma.SortOrder
|
||||
bio?: Prisma.SortOrder
|
||||
createdAt?: Prisma.SortOrder
|
||||
updatedAt?: Prisma.SortOrder
|
||||
}
|
||||
|
|
@ -342,6 +384,8 @@ export type usersMinOrderByAggregateInput = {
|
|||
name?: Prisma.SortOrder
|
||||
email?: Prisma.SortOrder
|
||||
password?: Prisma.SortOrder
|
||||
profilePhoto?: Prisma.SortOrder
|
||||
bio?: Prisma.SortOrder
|
||||
createdAt?: Prisma.SortOrder
|
||||
updatedAt?: Prisma.SortOrder
|
||||
}
|
||||
|
|
@ -360,6 +404,10 @@ export type usersUpdateOneRequiredWithoutTokensNestedInput = {
|
|||
update?: Prisma.XOR<Prisma.XOR<Prisma.usersUpdateToOneWithWhereWithoutTokensInput, Prisma.usersUpdateWithoutTokensInput>, Prisma.usersUncheckedUpdateWithoutTokensInput>
|
||||
}
|
||||
|
||||
export type NullableStringFieldUpdateOperationsInput = {
|
||||
set?: string | null
|
||||
}
|
||||
|
||||
export type usersCreateNestedOneWithoutRidesInput = {
|
||||
create?: Prisma.XOR<Prisma.usersCreateWithoutRidesInput, Prisma.usersUncheckedCreateWithoutRidesInput>
|
||||
connectOrCreate?: Prisma.usersCreateOrConnectWithoutRidesInput
|
||||
|
|
@ -379,6 +427,8 @@ export type usersCreateWithoutTokensInput = {
|
|||
name: string
|
||||
email: string
|
||||
password: string
|
||||
profilePhoto?: string | null
|
||||
bio?: string | null
|
||||
createdAt?: Date | string
|
||||
updatedAt: Date | string
|
||||
rides?: Prisma.ridesCreateNestedManyWithoutUsersInput
|
||||
|
|
@ -389,6 +439,8 @@ export type usersUncheckedCreateWithoutTokensInput = {
|
|||
name: string
|
||||
email: string
|
||||
password: string
|
||||
profilePhoto?: string | null
|
||||
bio?: string | null
|
||||
createdAt?: Date | string
|
||||
updatedAt: Date | string
|
||||
rides?: Prisma.ridesUncheckedCreateNestedManyWithoutUsersInput
|
||||
|
|
@ -415,6 +467,8 @@ export type usersUpdateWithoutTokensInput = {
|
|||
name?: Prisma.StringFieldUpdateOperationsInput | string
|
||||
email?: Prisma.StringFieldUpdateOperationsInput | string
|
||||
password?: Prisma.StringFieldUpdateOperationsInput | string
|
||||
profilePhoto?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
|
||||
bio?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
|
||||
createdAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string
|
||||
updatedAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string
|
||||
rides?: Prisma.ridesUpdateManyWithoutUsersNestedInput
|
||||
|
|
@ -425,6 +479,8 @@ export type usersUncheckedUpdateWithoutTokensInput = {
|
|||
name?: Prisma.StringFieldUpdateOperationsInput | string
|
||||
email?: Prisma.StringFieldUpdateOperationsInput | string
|
||||
password?: Prisma.StringFieldUpdateOperationsInput | string
|
||||
profilePhoto?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
|
||||
bio?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
|
||||
createdAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string
|
||||
updatedAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string
|
||||
rides?: Prisma.ridesUncheckedUpdateManyWithoutUsersNestedInput
|
||||
|
|
@ -435,6 +491,8 @@ export type usersCreateWithoutRidesInput = {
|
|||
name: string
|
||||
email: string
|
||||
password: string
|
||||
profilePhoto?: string | null
|
||||
bio?: string | null
|
||||
createdAt?: Date | string
|
||||
updatedAt: Date | string
|
||||
tokens?: Prisma.tokensCreateNestedManyWithoutUsersInput
|
||||
|
|
@ -445,6 +503,8 @@ export type usersUncheckedCreateWithoutRidesInput = {
|
|||
name: string
|
||||
email: string
|
||||
password: string
|
||||
profilePhoto?: string | null
|
||||
bio?: string | null
|
||||
createdAt?: Date | string
|
||||
updatedAt: Date | string
|
||||
tokens?: Prisma.tokensUncheckedCreateNestedManyWithoutUsersInput
|
||||
|
|
@ -471,6 +531,8 @@ export type usersUpdateWithoutRidesInput = {
|
|||
name?: Prisma.StringFieldUpdateOperationsInput | string
|
||||
email?: Prisma.StringFieldUpdateOperationsInput | string
|
||||
password?: Prisma.StringFieldUpdateOperationsInput | string
|
||||
profilePhoto?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
|
||||
bio?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
|
||||
createdAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string
|
||||
updatedAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string
|
||||
tokens?: Prisma.tokensUpdateManyWithoutUsersNestedInput
|
||||
|
|
@ -481,6 +543,8 @@ export type usersUncheckedUpdateWithoutRidesInput = {
|
|||
name?: Prisma.StringFieldUpdateOperationsInput | string
|
||||
email?: Prisma.StringFieldUpdateOperationsInput | string
|
||||
password?: Prisma.StringFieldUpdateOperationsInput | string
|
||||
profilePhoto?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
|
||||
bio?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
|
||||
createdAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string
|
||||
updatedAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string
|
||||
tokens?: Prisma.tokensUncheckedUpdateManyWithoutUsersNestedInput
|
||||
|
|
@ -531,6 +595,8 @@ export type usersSelect<ExtArgs extends runtime.Types.Extensions.InternalArgs =
|
|||
name?: boolean
|
||||
email?: boolean
|
||||
password?: boolean
|
||||
profilePhoto?: boolean
|
||||
bio?: boolean
|
||||
createdAt?: boolean
|
||||
updatedAt?: boolean
|
||||
rides?: boolean | Prisma.users$ridesArgs<ExtArgs>
|
||||
|
|
@ -543,6 +609,8 @@ export type usersSelectCreateManyAndReturn<ExtArgs extends runtime.Types.Extensi
|
|||
name?: boolean
|
||||
email?: boolean
|
||||
password?: boolean
|
||||
profilePhoto?: boolean
|
||||
bio?: boolean
|
||||
createdAt?: boolean
|
||||
updatedAt?: boolean
|
||||
}, ExtArgs["result"]["users"]>
|
||||
|
|
@ -552,6 +620,8 @@ export type usersSelectUpdateManyAndReturn<ExtArgs extends runtime.Types.Extensi
|
|||
name?: boolean
|
||||
email?: boolean
|
||||
password?: boolean
|
||||
profilePhoto?: boolean
|
||||
bio?: boolean
|
||||
createdAt?: boolean
|
||||
updatedAt?: boolean
|
||||
}, ExtArgs["result"]["users"]>
|
||||
|
|
@ -561,11 +631,13 @@ export type usersSelectScalar = {
|
|||
name?: boolean
|
||||
email?: boolean
|
||||
password?: boolean
|
||||
profilePhoto?: boolean
|
||||
bio?: boolean
|
||||
createdAt?: boolean
|
||||
updatedAt?: boolean
|
||||
}
|
||||
|
||||
export type usersOmit<ExtArgs extends runtime.Types.Extensions.InternalArgs = runtime.Types.Extensions.DefaultArgs> = runtime.Types.Extensions.GetOmit<"id" | "name" | "email" | "password" | "createdAt" | "updatedAt", ExtArgs["result"]["users"]>
|
||||
export type usersOmit<ExtArgs extends runtime.Types.Extensions.InternalArgs = runtime.Types.Extensions.DefaultArgs> = runtime.Types.Extensions.GetOmit<"id" | "name" | "email" | "password" | "profilePhoto" | "bio" | "createdAt" | "updatedAt", ExtArgs["result"]["users"]>
|
||||
export type usersInclude<ExtArgs extends runtime.Types.Extensions.InternalArgs = runtime.Types.Extensions.DefaultArgs> = {
|
||||
rides?: boolean | Prisma.users$ridesArgs<ExtArgs>
|
||||
tokens?: boolean | Prisma.users$tokensArgs<ExtArgs>
|
||||
|
|
@ -585,6 +657,8 @@ export type $usersPayload<ExtArgs extends runtime.Types.Extensions.InternalArgs
|
|||
name: string
|
||||
email: string
|
||||
password: string
|
||||
profilePhoto: string | null
|
||||
bio: string | null
|
||||
createdAt: Date
|
||||
updatedAt: Date
|
||||
}, ExtArgs["result"]["users"]>
|
||||
|
|
@ -1016,6 +1090,8 @@ export interface usersFieldRefs {
|
|||
readonly name: Prisma.FieldRef<"users", 'String'>
|
||||
readonly email: Prisma.FieldRef<"users", 'String'>
|
||||
readonly password: Prisma.FieldRef<"users", 'String'>
|
||||
readonly profilePhoto: Prisma.FieldRef<"users", 'String'>
|
||||
readonly bio: Prisma.FieldRef<"users", 'String'>
|
||||
readonly createdAt: Prisma.FieldRef<"users", 'DateTime'>
|
||||
readonly updatedAt: Prisma.FieldRef<"users", 'DateTime'>
|
||||
}
|
||||
|
|
|
|||
|
|
@ -20,7 +20,14 @@ export async function createUser(data: {
|
|||
|
||||
export async function updateUser(
|
||||
id: string,
|
||||
data: Partial<{ name: string; email: string; password: string; updatedAt: Date }>
|
||||
data: Partial<{
|
||||
name: string;
|
||||
email: string;
|
||||
password: string;
|
||||
profilePhoto: string;
|
||||
bio: string;
|
||||
updatedAt: Date;
|
||||
}>
|
||||
) {
|
||||
return prisma.users.update({ where: { id }, data });
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,7 +7,9 @@ const router = Router();
|
|||
router.use(authenticate);
|
||||
|
||||
router.get('/me', usersController.get);
|
||||
router.get('/profile', usersController.getProfile);
|
||||
router.put('/me', usersController.update);
|
||||
router.patch('/profile', usersController.updateProfile);
|
||||
router.delete('/me', usersController.remove);
|
||||
|
||||
export default router;
|
||||
|
|
@ -3,15 +3,40 @@ import { z } from 'zod';
|
|||
import * as usersRepo from '../repositories/users.repository.js';
|
||||
|
||||
export const updateUserSchema = z.object({
|
||||
name: z.string().check(z.minLength(2)).optional(),
|
||||
name: z.string().min(2).optional(),
|
||||
email: z.email().optional(),
|
||||
password: z.string().check(z.minLength(6)).optional(),
|
||||
password: z.string().min(6).optional(),
|
||||
});
|
||||
|
||||
export const updateProfileSchema = z.object({
|
||||
name: z.string().min(2).optional(),
|
||||
profilePhoto: z.string().optional(),
|
||||
bio: z.string().max(500).optional(),
|
||||
});
|
||||
|
||||
export async function getUser(id: string) {
|
||||
const user = await usersRepo.findUserById(id);
|
||||
if (!user) throw new Error('User not found');
|
||||
return { id: user.id, name: user.name, email: user.email, createdAt: user.createdAt };
|
||||
return {
|
||||
id: user.id,
|
||||
name: user.name,
|
||||
email: user.email,
|
||||
profilePhoto: user.profilePhoto,
|
||||
bio: user.bio,
|
||||
createdAt: user.createdAt,
|
||||
};
|
||||
}
|
||||
|
||||
export async function getProfile(id: string) {
|
||||
const user = await usersRepo.findUserById(id);
|
||||
if (!user) throw new Error('User not found');
|
||||
return {
|
||||
id: user.id,
|
||||
name: user.name,
|
||||
email: user.email,
|
||||
profilePhoto: user.profilePhoto,
|
||||
bio: user.bio,
|
||||
};
|
||||
}
|
||||
|
||||
export async function updateUser(id: string, input: z.infer<typeof updateUserSchema>) {
|
||||
|
|
@ -28,6 +53,26 @@ export async function updateUser(id: string, input: z.infer<typeof updateUserSch
|
|||
return { id: updated.id, name: updated.name, email: updated.email };
|
||||
}
|
||||
|
||||
export async function updateProfile(id: string, input: z.infer<typeof updateProfileSchema>) {
|
||||
const user = await usersRepo.findUserById(id);
|
||||
if (!user) throw new Error('User not found');
|
||||
|
||||
const data: Parameters<typeof usersRepo.updateUser>[1] = { updatedAt: new Date() };
|
||||
|
||||
if (input.name) data.name = input.name;
|
||||
if (input.profilePhoto !== undefined) data.profilePhoto = input.profilePhoto;
|
||||
if (input.bio !== undefined) data.bio = input.bio;
|
||||
|
||||
const updated = await usersRepo.updateUser(id, data);
|
||||
return {
|
||||
id: updated.id,
|
||||
name: updated.name,
|
||||
email: updated.email,
|
||||
profilePhoto: updated.profilePhoto,
|
||||
bio: updated.bio,
|
||||
};
|
||||
}
|
||||
|
||||
export async function deleteUser(id: string) {
|
||||
const user = await usersRepo.findUserById(id);
|
||||
if (!user) throw new Error('User not found');
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue