init db with migration, create users table
This commit is contained in:
@@ -5,12 +5,12 @@
|
||||
"main": "dist/index.js",
|
||||
"types": "dist/index.d.ts",
|
||||
"scripts": {
|
||||
"build": "tsc"
|
||||
"build": "tsc --watch"
|
||||
},
|
||||
"keywords": [],
|
||||
"author": "",
|
||||
"license": "ISC",
|
||||
"dependencies": {
|
||||
"zod": "^3.22.3"
|
||||
"zod": "^3.25.76"
|
||||
}
|
||||
}
|
||||
10
packages/common/src/api-services/auth/auth-api-service.ts
Normal file
10
packages/common/src/api-services/auth/auth-api-service.ts
Normal file
@@ -0,0 +1,10 @@
|
||||
export interface AuthApiService {
|
||||
postCredentials(): Promise<string>;
|
||||
}
|
||||
|
||||
export const AuthApiService: Record<keyof AuthApiService, string> & {
|
||||
baseUrl: string;
|
||||
} = {
|
||||
baseUrl: "auth",
|
||||
postCredentials: "credentials",
|
||||
};
|
||||
1
packages/common/src/api-services/auth/index.ts
Normal file
1
packages/common/src/api-services/auth/index.ts
Normal file
@@ -0,0 +1 @@
|
||||
export * from "./auth-api-service";
|
||||
1
packages/common/src/api-services/index.ts
Normal file
1
packages/common/src/api-services/index.ts
Normal file
@@ -0,0 +1 @@
|
||||
export * from "./auth";
|
||||
@@ -1 +1,2 @@
|
||||
export * from "./contracts/index";
|
||||
export * from "./api-services";
|
||||
export * from "./models";
|
||||
|
||||
14
packages/common/src/models/auth/credential-auth.ts
Normal file
14
packages/common/src/models/auth/credential-auth.ts
Normal file
@@ -0,0 +1,14 @@
|
||||
import z from "zod";
|
||||
|
||||
export const credentialAuthParser = z.object({
|
||||
email: z.string().email({ message: "invalid email" }),
|
||||
password: z.string({ message: "invalid password" }),
|
||||
});
|
||||
|
||||
export const credentialAuthResponse = z.object({
|
||||
accessToken: z.string({ message: "invalid access tokens" }),
|
||||
});
|
||||
|
||||
export type CredentialAuth = z.infer<typeof credentialAuthParser>;
|
||||
|
||||
export type CredentialAuthResponse = z.infer<typeof credentialAuthResponse>;
|
||||
1
packages/common/src/models/index.ts
Normal file
1
packages/common/src/models/index.ts
Normal file
@@ -0,0 +1 @@
|
||||
export * from "./users";
|
||||
1
packages/common/src/models/users/index.ts
Normal file
1
packages/common/src/models/users/index.ts
Normal file
@@ -0,0 +1 @@
|
||||
export * from "./user";
|
||||
16
packages/common/src/models/users/user.ts
Normal file
16
packages/common/src/models/users/user.ts
Normal file
@@ -0,0 +1,16 @@
|
||||
import z from "zod";
|
||||
|
||||
export enum UserTypeEnum {
|
||||
Customer = "customer",
|
||||
Professional = "professional",
|
||||
}
|
||||
|
||||
export const userParser = z.object({
|
||||
id: z.string({ message: "inavlid user id" }),
|
||||
firstName: z.string({ message: "invalid user first name" }),
|
||||
lastName: z.string({ message: "invalid last name" }),
|
||||
email: z.string().email({ message: "invalid email" }),
|
||||
type: z.nativeEnum(UserTypeEnum, { message: "invalid user type" }),
|
||||
});
|
||||
|
||||
export type User = z.infer<typeof userParser>;
|
||||
Reference in New Issue
Block a user