add cache to auth

This commit is contained in:
2025-01-24 19:24:27 +05:30
parent 59ce61d3a6
commit 405338c314
8 changed files with 125 additions and 67 deletions

View File

@@ -1,37 +1,41 @@
import { buildJsonSchemas } from "fastify-zod";
import mongoose from "mongoose";
import mongoose, { InferSchemaType } from "mongoose";
import { z } from "zod";
import { roles } from "../utils/roles";
export const userModel = mongoose.model(
"user",
new mongoose.Schema({
tenantId: {
type: String,
required: true,
},
pid: {
type: String,
unique: true,
required: true,
},
orgId: mongoose.Types.ObjectId,
firstName: String,
lastName: String,
name: String,
email: {
type: String,
unique: true,
required: true,
},
avatar: String,
status: String,
role: String,
createdAt: Date,
createdBy: mongoose.Types.ObjectId,
lastLogin: Date,
})
);
const userSchema = new mongoose.Schema({
tenantId: {
type: String,
required: true,
},
pid: {
type: String,
unique: true,
required: true,
},
orgId: mongoose.Types.ObjectId,
firstName: String,
lastName: String,
name: String,
email: {
type: String,
unique: true,
required: true,
},
avatar: String,
status: String,
role: {
type: String,
required: true,
},
createdAt: Date,
createdBy: mongoose.Types.ObjectId,
lastLogin: Date,
});
export const userModel = mongoose.model("user", userSchema);
export type User = InferSchemaType<typeof userSchema>;
const userCore = {
firstName: z.string().max(30),