add models dir and update zod user models
This commit is contained in:
parent
9eff4d2293
commit
13bba32a8d
|
|
@ -1,4 +1,5 @@
|
|||
import { getUser, UserLoginModel } from '@/controller/UserController';
|
||||
import { getUser } from '@/controller/UserController';
|
||||
import UserLoginModel from '@/models/UserLoginModel';
|
||||
import { comparePassword } from '@/controller/AuthController';
|
||||
import { Request, Response } from 'express';
|
||||
import { User } from '@prisma/client';
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
import { newUser, UserModel } from '@/controller/UserController';
|
||||
import { newUser } from '@/controller/UserController';
|
||||
import UserModel from '@/models/UserModel';
|
||||
import { hashPassword } from '@/controller/AuthController';
|
||||
import { User } from '@prisma/client';
|
||||
import { Request, Response } from 'express';
|
||||
|
|
|
|||
|
|
@ -1,17 +1,4 @@
|
|||
import { PrismaClient, User } from '@prisma/client';
|
||||
import * as z from 'zod';
|
||||
|
||||
const UserModel = z.object({
|
||||
email: z.string().email(),
|
||||
password: z.string(),
|
||||
firstname: z.string(),
|
||||
lastname: z.string(),
|
||||
});
|
||||
|
||||
const UserLoginModel = z.object({
|
||||
email: z.string().email(),
|
||||
password: z.string(),
|
||||
});
|
||||
|
||||
const prisma = new PrismaClient();
|
||||
|
||||
|
|
@ -33,4 +20,4 @@ const newUser = (user: User) => {
|
|||
return prismaUser;
|
||||
};
|
||||
|
||||
export { getUser, newUser, UserModel, UserLoginModel };
|
||||
export { getUser, newUser };
|
||||
|
|
|
|||
|
|
@ -0,0 +1,8 @@
|
|||
import { z } from 'zod';
|
||||
|
||||
const UserLoginModel = z.object({
|
||||
email: z.string().email(),
|
||||
password: z.string(),
|
||||
});
|
||||
|
||||
export default UserLoginModel;
|
||||
|
|
@ -0,0 +1,13 @@
|
|||
import { z } from 'zod';
|
||||
|
||||
const UserModel = z.object({
|
||||
id: z.string().optional(),
|
||||
email: z.string().email(),
|
||||
password: z.string(),
|
||||
firstname: z.string(),
|
||||
lastname: z.string(),
|
||||
role: z.string().default('user'),
|
||||
posts: z.array(z.string()).optional(),
|
||||
});
|
||||
|
||||
export default UserModel;
|
||||
Loading…
Reference in New Issue