feat: add credentials authentication (#1)
This commit is contained in:
1
packages/validation/index.ts
Normal file
1
packages/validation/index.ts
Normal file
@@ -0,0 +1 @@
|
||||
export * from "./src";
|
||||
38
packages/validation/package.json
Normal file
38
packages/validation/package.json
Normal file
@@ -0,0 +1,38 @@
|
||||
{
|
||||
"name": "@alparr/validation",
|
||||
"private": true,
|
||||
"version": "0.1.0",
|
||||
"exports": {
|
||||
".": "./index.ts"
|
||||
},
|
||||
"typesVersions": {
|
||||
"*": {
|
||||
"*": [
|
||||
"src/*"
|
||||
]
|
||||
}
|
||||
},
|
||||
"license": "MIT",
|
||||
"scripts": {
|
||||
"clean": "rm -rf .turbo node_modules",
|
||||
"lint": "eslint .",
|
||||
"format": "prettier --check . --ignore-path ../../.gitignore",
|
||||
"typecheck": "tsc --noEmit"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@alparr/eslint-config": "workspace:^0.2.0",
|
||||
"@alparr/prettier-config": "workspace:^0.1.0",
|
||||
"@alparr/tsconfig": "workspace:^0.1.0",
|
||||
"eslint": "^8.53.0",
|
||||
"typescript": "^5.3.3"
|
||||
},
|
||||
"eslintConfig": {
|
||||
"extends": [
|
||||
"@alparr/eslint-config/base"
|
||||
]
|
||||
},
|
||||
"prettier": "@alparr/prettier-config",
|
||||
"dependencies": {
|
||||
"zod": "^3.22.2"
|
||||
}
|
||||
}
|
||||
1
packages/validation/src/index.ts
Normal file
1
packages/validation/src/index.ts
Normal file
@@ -0,0 +1 @@
|
||||
export * from "./user";
|
||||
20
packages/validation/src/user.ts
Normal file
20
packages/validation/src/user.ts
Normal file
@@ -0,0 +1,20 @@
|
||||
import { z } from "zod";
|
||||
|
||||
const usernameSchema = z.string().min(3).max(255);
|
||||
const passwordSchema = z.string().min(8).max(255);
|
||||
|
||||
export const initUserSchema = z
|
||||
.object({
|
||||
username: usernameSchema,
|
||||
password: passwordSchema,
|
||||
repeatPassword: z.string(),
|
||||
})
|
||||
.refine((data) => data.password === data.repeatPassword, {
|
||||
path: ["repeatPassword"],
|
||||
message: "Passwords do not match",
|
||||
});
|
||||
|
||||
export const signInSchema = z.object({
|
||||
name: z.string(),
|
||||
password: z.string(),
|
||||
});
|
||||
8
packages/validation/tsconfig.json
Normal file
8
packages/validation/tsconfig.json
Normal file
@@ -0,0 +1,8 @@
|
||||
{
|
||||
"extends": "@alparr/tsconfig/base.json",
|
||||
"compilerOptions": {
|
||||
"tsBuildInfoFile": "node_modules/.cache/tsbuildinfo.json"
|
||||
},
|
||||
"include": ["*.ts", "src"],
|
||||
"exclude": ["node_modules"]
|
||||
}
|
||||
Reference in New Issue
Block a user