Initial Commit

This commit is contained in:
2024-12-19 13:54:15 +05:30
commit 970a972b11
17 changed files with 1487 additions and 0 deletions

View File

@@ -0,0 +1,52 @@
import { buildJsonSchemas } from "fastify-zod";
import mongoose from "mongoose";
import { z } from "zod";
export const orgModel = mongoose.model(
"organization",
new mongoose.Schema({
tenantId: String,
pid: {
type: String,
unique: true,
},
name: String,
domain: {
type: String,
unique: true,
},
avatar: String,
type: String,
status: String,
createdAt: Date,
createdBy: mongoose.Types.ObjectId,
})
);
const orgCore = {
name: z.string().max(30),
domain: z.string().max(30),
avatar: z.string().url().optional(),
type: z.enum(["county", "builder"], {
message: "Must be county or builder",
}),
};
const createOrgInput = z.object({
...orgCore,
});
const createOrgResponse = z.object({
pid: z.string(),
...orgCore,
});
export type CreateOrgInput = z.infer<typeof createOrgInput>;
export const { schemas: orgSchemas, $ref: $org } = buildJsonSchemas(
{
createOrgInput,
createOrgResponse,
},
{ $id: "org" }
);