Added the ProjectPlan interface to the Project.ts

This commit is contained in:
Mathias Wagner 2023-01-22 18:02:13 +01:00
parent 305c72814c
commit bd6e5f4fd6
Signed by: Mathias
GPG Key ID: B8DC354B0A1F5B44

View File

@ -2,6 +2,10 @@ import { model, ObjectId, Schema } from "mongoose";
import crypto from "crypto"; import crypto from "crypto";
import { fieldEncryption } from "mongoose-field-encryption"; import { fieldEncryption } from "mongoose-field-encryption";
export enum IProjectPlan {
PERSONAL = "personal", PLUS = "plus", PRO = "pro"
}
export interface IProjectDefaults { export interface IProjectDefaults {
licenseKey: string, licenseKey: string,
groups: string[], groups: string[],
@ -14,7 +18,8 @@ export interface IProject {
name: string, name: string,
creatorId: ObjectId, creatorId: ObjectId,
validationKey: string, validationKey: string,
defaults: IProjectDefaults defaults: IProjectDefaults,
plan: IProjectPlan
} }
const ProjectSchema = new Schema<IProject>({ const ProjectSchema = new Schema<IProject>({
@ -34,10 +39,14 @@ const ProjectSchema = new Schema<IProject>({
type: Object, type: Object,
default: { licenseKey: "NNUN-UUNN-UNAU-NAAN", groups: [], expirationDate: new Date(0), permissions: [] }, default: { licenseKey: "NNUN-UUNN-UNAU-NAAN", groups: [], expirationDate: new Date(0), permissions: [] },
}, },
plan: {
type: String,
default: IProjectPlan.PERSONAL
}
}); });
ProjectSchema.plugin(fieldEncryption, { ProjectSchema.plugin(fieldEncryption, {
fields: ["name", "creatorId", "validationKey", "defaults"], fields: ["name", "creatorId", "validationKey", "defaults", "plan"],
secret: process.env.ENC_KEY, secret: process.env.ENC_KEY,
saltGenerator: () => process.env.SIG_KEY saltGenerator: () => process.env.SIG_KEY
}); });