summaryrefslogtreecommitdiff
path: root/src/models
diff options
context:
space:
mode:
authorRaphael Kabo <raphaelkabo@hey.com>2023-10-06 12:32:37 +0100
committerRaphael Kabo <raphaelkabo@hey.com>2023-10-06 12:32:37 +0100
commit63cf813f4a284cfaec8114c623d13e9d650569f6 (patch)
tree655185cce75f8d6632f8761e62c64bd53be71da9 /src/models
parent6e5e2e5fc55f5ff1c78c41d0acbdcf82221fc2cf (diff)
Add Typescript interfaces for Mongoose models
Diffstat (limited to 'src/models')
-rw-r--r--[-rwxr-xr-x]src/models/Event.ts (renamed from src/models/Event.js)75
-rwxr-xr-xsrc/models/EventGroup.ts (renamed from src/models/EventGroup.js)20
-rwxr-xr-xsrc/models/Log.ts (renamed from src/models/Log.js)9
3 files changed, 101 insertions, 3 deletions
diff --git a/src/models/Event.js b/src/models/Event.ts
index 63a03ae..fb8630c 100755..100644
--- a/src/models/Event.js
+++ b/src/models/Event.ts
@@ -1,5 +1,78 @@
import mongoose from "mongoose";
+export interface IAttendee {
+ name?: string;
+ status?: string;
+ email?: string;
+ removalPassword?: string;
+ id?: string;
+ number?: number;
+ created?: Date;
+}
+
+export interface IReply {
+ id: string;
+ author: string;
+ content: string;
+ timestamp: Date;
+}
+
+export interface IComment {
+ id: string;
+ author: string;
+ content: string;
+ timestamp: Date;
+ activityJson?: string;
+ actorJson?: string;
+ activityId?: string;
+ actorId?: string;
+ replies?: IReply[];
+}
+
+export interface IFollower {
+ followId?: string;
+ actorId?: string;
+ actorJson?: string;
+ name?: string;
+}
+
+export interface IActivityPubMessage {
+ id?: string;
+ content?: string;
+}
+
+export interface IEvent extends mongoose.Document {
+ id: string;
+ type: string;
+ name: string;
+ location: string;
+ start: Date;
+ end: Date;
+ timezone: string;
+ description: string;
+ image?: string;
+ url?: string;
+ creatorEmail?: string;
+ hostName?: string;
+ viewPassword?: string;
+ editPassword?: string;
+ editToken?: string;
+ eventGroup?: mongoose.Types.ObjectId;
+ usersCanAttend?: boolean;
+ showUsersList?: boolean;
+ usersCanComment?: boolean;
+ firstLoad?: boolean;
+ attendees?: IAttendee[];
+ maxAttendees?: number;
+ comments?: IComment[];
+ activityPubActor?: string;
+ activityPubEvent?: string;
+ publicKey?: string;
+ privateKey?: string;
+ followers?: IFollower[];
+ activityPubMessages?: IActivityPubMessage[];
+}
+
const Attendees = new mongoose.Schema({
name: {
type: String,
@@ -256,4 +329,4 @@ const EventSchema = new mongoose.Schema({
activityPubMessages: [ActivityPubMessages],
});
-export default mongoose.model("Event", EventSchema);
+export default mongoose.model<IEvent>("Event", EventSchema);
diff --git a/src/models/EventGroup.js b/src/models/EventGroup.ts
index f19e374..f097843 100755
--- a/src/models/EventGroup.js
+++ b/src/models/EventGroup.ts
@@ -1,5 +1,23 @@
import mongoose from "mongoose";
+export interface ISubscriber {
+ email?: string;
+}
+
+export interface IEventGroup extends mongoose.Document {
+ id: string;
+ name: string;
+ description: string;
+ image?: string;
+ url?: string;
+ creatorEmail?: string;
+ hostName?: string;
+ editToken?: string;
+ firstLoad?: boolean;
+ events?: mongoose.Types.ObjectId[];
+ subscribers?: ISubscriber[];
+}
+
const Subscriber = new mongoose.Schema({
email: {
type: String,
@@ -54,4 +72,4 @@ const EventGroupSchema = new mongoose.Schema({
subscribers: [Subscriber],
});
-export default mongoose.model("EventGroup", EventGroupSchema);
+export default mongoose.model<IEventGroup>("EventGroup", EventGroupSchema);
diff --git a/src/models/Log.js b/src/models/Log.ts
index f165900..8f905fd 100755
--- a/src/models/Log.js
+++ b/src/models/Log.ts
@@ -1,5 +1,12 @@
import mongoose from "mongoose";
+export interface ILog extends mongoose.Document {
+ status: string;
+ process: string;
+ message: string;
+ timestamp: Date;
+}
+
const LogSchema = new mongoose.Schema({
status: {
type: String,
@@ -23,4 +30,4 @@ const LogSchema = new mongoose.Schema({
},
});
-export default mongoose.model("Log", LogSchema);
+export default mongoose.model<ILog>("Log", LogSchema);