@amohamud23/notihub 1.0.63 → 1.0.64

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (72) hide show
  1. package/package.json +3 -8
  2. package/src/index.ts +4 -0
  3. package/src/models/CustomerMinifiedModel.ts +17 -0
  4. package/src/models/CustomerModel.ts +13 -0
  5. package/src/models/NotiHubStatsHistoryModel.ts +19 -0
  6. package/src/models/NotiHubStatsModel.ts +22 -0
  7. package/src/models/NotiTypeModel.ts +13 -0
  8. package/src/models/NotificationModel.ts +24 -0
  9. package/src/models/NotificationStatsModel.ts +20 -0
  10. package/src/models/SubscriptionModel.ts +20 -0
  11. package/src/models/SubscriptionTypeModel.ts +20 -0
  12. package/src/models/UserModel.ts +11 -0
  13. package/src/models/index.ts +21 -0
  14. package/src/models/schemas/CustomerMinifiedSchema.ts +14 -0
  15. package/src/models/schemas/CustomerSchema.ts +14 -0
  16. package/src/models/schemas/NotiTypeSchema.ts +11 -0
  17. package/src/models/schemas/NotificationSchema.ts +15 -0
  18. package/src/models/schemas/NotificationStatsHistorySchema.ts +12 -0
  19. package/src/models/schemas/NotificationStatsSchema.ts +9 -0
  20. package/src/models/schemas/SubscriptionSchema.ts +13 -0
  21. package/src/models/schemas/SubscriptionTypeSchema.ts +7 -0
  22. package/src/models/schemas/UserSchema.ts +11 -0
  23. package/src/types.ts +161 -0
  24. package/src/util/DateUtil.ts +60 -0
  25. package/tsconfig.json +109 -0
  26. package/dist/index.d.ts +0 -3
  27. package/dist/index.js +0 -19
  28. package/dist/lib/util/DateUtil.js +0 -56
  29. package/dist/src/models/CustomerMinifiedModel.d.ts +0 -33
  30. package/dist/src/models/CustomerMinifiedModel.js +0 -12
  31. package/dist/src/models/CustomerModel.d.ts +0 -33
  32. package/dist/src/models/CustomerModel.js +0 -14
  33. package/dist/src/models/NotiHubStatsHistoryModel.d.ts +0 -33
  34. package/dist/src/models/NotiHubStatsHistoryModel.js +0 -14
  35. package/dist/src/models/NotiHubStatsModel.d.ts +0 -33
  36. package/dist/src/models/NotiHubStatsModel.js +0 -17
  37. package/dist/src/models/NotiTypeModel.d.ts +0 -33
  38. package/dist/src/models/NotiTypeModel.js +0 -14
  39. package/dist/src/models/NotificationModel.d.ts +0 -33
  40. package/dist/src/models/NotificationModel.js +0 -19
  41. package/dist/src/models/NotificationStatsModel.d.ts +0 -33
  42. package/dist/src/models/NotificationStatsModel.js +0 -15
  43. package/dist/src/models/SubscriptionModel.d.ts +0 -33
  44. package/dist/src/models/SubscriptionModel.js +0 -14
  45. package/dist/src/models/SubscriptionTypeModel.d.ts +0 -33
  46. package/dist/src/models/SubscriptionTypeModel.js +0 -14
  47. package/dist/src/models/UserModel.d.ts +0 -33
  48. package/dist/src/models/UserModel.js +0 -12
  49. package/dist/src/models/index.d.ts +0 -74
  50. package/dist/src/models/index.js +0 -25
  51. package/dist/src/models/schemas/CustomerMinifiedSchema.d.ts +0 -51
  52. package/dist/src/models/schemas/CustomerMinifiedSchema.js +0 -14
  53. package/dist/src/models/schemas/CustomerSchema.d.ts +0 -73
  54. package/dist/src/models/schemas/CustomerSchema.js +0 -17
  55. package/dist/src/models/schemas/NotiTypeSchema.d.ts +0 -83
  56. package/dist/src/models/schemas/NotiTypeSchema.js +0 -14
  57. package/dist/src/models/schemas/NotificationSchema.d.ts +0 -76
  58. package/dist/src/models/schemas/NotificationSchema.js +0 -18
  59. package/dist/src/models/schemas/NotificationStatsHistorySchema.d.ts +0 -53
  60. package/dist/src/models/schemas/NotificationStatsHistorySchema.js +0 -12
  61. package/dist/src/models/schemas/NotificationStatsSchema.d.ts +0 -13
  62. package/dist/src/models/schemas/NotificationStatsSchema.js +0 -8
  63. package/dist/src/models/schemas/SubscriptionSchema.d.ts +0 -106
  64. package/dist/src/models/schemas/SubscriptionSchema.js +0 -16
  65. package/dist/src/models/schemas/SubscriptionTypeSchema.d.ts +0 -15
  66. package/dist/src/models/schemas/SubscriptionTypeSchema.js +0 -8
  67. package/dist/src/models/schemas/UserSchema.d.ts +0 -50
  68. package/dist/src/models/schemas/UserSchema.js +0 -11
  69. package/dist/src/util/DateUtil.d.ts +0 -7
  70. package/dist/src/util/DateUtil.js +0 -56
  71. package/dist/types.d.ts +0 -140
  72. package/dist/types.js +0 -2
package/package.json CHANGED
@@ -1,14 +1,9 @@
1
1
  {
2
2
  "name": "@amohamud23/notihub",
3
- "version": "1.0.63",
3
+ "version": "1.0.64",
4
4
  "description": "Notihub Package",
5
- "main": "dist/index.js",
6
- "types": "src/types/index.d.ts",
7
- "files": [
8
- "dist/index.js",
9
- "index.d.ts",
10
- "dist"
11
- ],
5
+ "main": "./dist/index.js",
6
+ "types": "./dist/index.d.ts",
12
7
  "scripts": {
13
8
  "build": "npx tsc",
14
9
  "test": "echo \"Error: no test specified\" && exit 1"
package/src/index.ts ADDED
@@ -0,0 +1,4 @@
1
+ export * from "./util/DateUtil";
2
+ export * from "./models/index";
3
+
4
+ export * from "./types";
@@ -0,0 +1,17 @@
1
+ import { Schema, model } from "mongoose";
2
+ import CustomerMinifiedSchema from "./schemas/CustomerMinifiedSchema";
3
+ import { INotiHubCustomerMinified } from "../types";
4
+
5
+ // 2. Create a Schema corresponding to the document interface.
6
+ const customerMinifiedSchema = new Schema<INotiHubCustomerMinified>(
7
+ CustomerMinifiedSchema,
8
+ { timestamps: true }
9
+ );
10
+
11
+ // 3. Create a Model.
12
+ const CustomerMinified = model<INotiHubCustomerMinified>(
13
+ "CustomerMinified",
14
+ customerMinifiedSchema
15
+ );
16
+
17
+ export default CustomerMinified;
@@ -0,0 +1,13 @@
1
+ import { Schema, model } from "mongoose";
2
+ import CustomerSchema from "./schemas/CustomerSchema";
3
+ import { INotiHubCustomer } from "../types";
4
+
5
+ // 2. Create a Schema corresponding to the document interface.
6
+ const customerSchema = new Schema<INotiHubCustomer>(CustomerSchema, {
7
+ timestamps: true,
8
+ });
9
+
10
+ // 3. Create a Model.
11
+ const Customer = model<INotiHubCustomer>("Customer", customerSchema);
12
+
13
+ export default Customer;
@@ -0,0 +1,19 @@
1
+ import { Schema, model } from "mongoose";
2
+ import NotihubStatsHistorySchema from "./schemas/NotificationStatsHistorySchema";
3
+ import { INotiHubStatsHistory } from "../types";
4
+
5
+ // 2. Create a Schema corresponding to the document interface.
6
+ const notihubStatsHistorySchema = new Schema<INotiHubStatsHistory>(
7
+ NotihubStatsHistorySchema,
8
+ {
9
+ timestamps: true,
10
+ }
11
+ );
12
+
13
+ // 3. Create a Model.
14
+ const NotiHubStatsHistory = model<INotiHubStatsHistory>(
15
+ "INotiHubStatsHistories",
16
+ notihubStatsHistorySchema
17
+ );
18
+
19
+ export default NotiHubStatsHistory;
@@ -0,0 +1,22 @@
1
+ import { Schema, model } from "mongoose";
2
+ import CustomerSchema from "./schemas/CustomerSchema";
3
+ import { INotiHubStats } from "../types";
4
+
5
+ // 2. Create a Schema corresponding to the document interface.
6
+ const entityNotiHubStatsSchema = new Schema<INotiHubStats>(
7
+ {
8
+ entity: CustomerSchema,
9
+ notifications: { type: Number, default: 0 },
10
+ subscription: { type: Number, default: 0 },
11
+ views: { type: Number, default: 0 },
12
+ },
13
+ { timestamps: true }
14
+ );
15
+
16
+ // 3. Create a Model.
17
+ const EntityNotiHubStats = model<INotiHubStats>(
18
+ "EntityNotiHubStats",
19
+ entityNotiHubStatsSchema
20
+ );
21
+
22
+ export default EntityNotiHubStats;
@@ -0,0 +1,13 @@
1
+ import { Schema, model } from "mongoose";
2
+ import NotiTypeSchema from "./schemas/NotiTypeSchema";
3
+ import { INotiType } from "../types";
4
+
5
+ // 2. Create a Schema corresponding to the document interface.
6
+ const notiTypeSchema = new Schema<INotiType>(NotiTypeSchema, {
7
+ timestamps: true,
8
+ });
9
+
10
+ // 3. Create a Model.
11
+ const NotiTypeModel = model<INotiType>("NotiTypes", notiTypeSchema);
12
+
13
+ export default NotiTypeModel;
@@ -0,0 +1,24 @@
1
+ import { Schema, model, ObjectId } from "mongoose";
2
+ import CustomerSchema from "./schemas/CustomerSchema";
3
+ import { INotiHubNotification } from "../types";
4
+
5
+ // 2. Create a Schema corresponding to the document interface.
6
+ const notificationSchema = new Schema<INotiHubNotification>(
7
+ {
8
+ title: { type: String, required: true },
9
+ message: { type: String, required: true },
10
+ type: { type: String, required: true },
11
+ body: { type: String },
12
+ entityId: { type: String, required: true },
13
+ entityMinified: CustomerSchema,
14
+ },
15
+ { timestamps: true }
16
+ );
17
+
18
+ // 3. Create a Model.
19
+ const NotificationModel = model<INotiHubNotification>(
20
+ "Notification",
21
+ notificationSchema
22
+ );
23
+
24
+ export default NotificationModel;
@@ -0,0 +1,20 @@
1
+ import { Schema, model } from "mongoose";
2
+ import NotificationSchema from "./schemas/NotificationSchema";
3
+ import { INotiHubNotificationStats } from "../types";
4
+
5
+ // 2. Create a Schema corresponding to the document interface.
6
+ const notificationSchema = new Schema<INotiHubNotificationStats>(
7
+ {
8
+ notification: NotificationSchema,
9
+ views: { type: Number, default: 0 },
10
+ },
11
+ { timestamps: true }
12
+ );
13
+
14
+ // 3. Create a Model.
15
+ const NotificationStatsModel = model<INotiHubNotificationStats>(
16
+ "NotificationStats",
17
+ notificationSchema
18
+ );
19
+
20
+ export default NotificationStatsModel;
@@ -0,0 +1,20 @@
1
+ import mongoose, { Document, Schema, Types, model } from "mongoose";
2
+
3
+ import SubscriptionSchema from "./schemas/SubscriptionSchema";
4
+ import { INotiHubSubscription } from "../types";
5
+
6
+ // 2. Create a Schema corresponding to the document interface.
7
+ const subscriptionSchema = new Schema<INotiHubSubscription>(
8
+ SubscriptionSchema,
9
+ {
10
+ timestamps: true,
11
+ }
12
+ );
13
+
14
+ // 3. Create a Model.
15
+ const Subscription = model<INotiHubSubscription>(
16
+ "Subscriptions",
17
+ subscriptionSchema
18
+ );
19
+
20
+ export default Subscription;
@@ -0,0 +1,20 @@
1
+ import { ObjectId } from "mongodb";
2
+ import { Schema, model } from "mongoose";
3
+ import SubscriptionSchema from "./schemas/SubscriptionTypeSchema";
4
+ import { IUserSubscribeNotifier } from "../types";
5
+
6
+ // 2. Create a Schema corresponding to the document interface.
7
+ const subscriptionSchema = new Schema<IUserSubscribeNotifier>(
8
+ SubscriptionSchema,
9
+ {
10
+ timestamps: true,
11
+ }
12
+ );
13
+
14
+ // 3. Create a Model.
15
+ const SubscriptionType = model<IUserSubscribeNotifier>(
16
+ "SubscriptionTypes",
17
+ subscriptionSchema
18
+ );
19
+
20
+ export default SubscriptionType;
@@ -0,0 +1,11 @@
1
+ import { Schema, model } from "mongoose";
2
+ import UserSchema from "./schemas/UserSchema";
3
+ import { INotiHubUser } from "../types";
4
+
5
+ // 2. Create a Schema corresponding to the document interface.
6
+ const userSchema = new Schema<INotiHubUser>(UserSchema, { timestamps: true });
7
+
8
+ // 3. Create a Model.
9
+ const UserModel = model<INotiHubUser>("User", userSchema);
10
+
11
+ export default UserModel;
@@ -0,0 +1,21 @@
1
+ import UserModel from "./UserModel";
2
+ import Subscription from "./SubscriptionModel";
3
+ import NotiTypeModel from "./NotiTypeModel";
4
+ import NotiHubStatsHistory from "./NotiHubStatsHistoryModel";
5
+ import NotificationStatsModel from "./NotificationStatsModel";
6
+ import NotificationModel from "./NotificationModel";
7
+ import Customer from "./CustomerModel";
8
+ import CustomerMinified from "./CustomerMinifiedModel";
9
+ import SubscriptionType from "./SubscriptionTypeModel";
10
+
11
+ export default {
12
+ UserModel,
13
+ Subscription,
14
+ SubscriptionType,
15
+ NotiTypeModel,
16
+ NotificationStatsModel,
17
+ NotiHubStatsHistory,
18
+ NotificationModel,
19
+ Customer,
20
+ CustomerMinified,
21
+ };
@@ -0,0 +1,14 @@
1
+ import { Schema, model } from "mongoose";
2
+
3
+ // 2. Create a Schema corresponding to the document interface.
4
+ const CustomerMinifiedSchema = {
5
+ id: { type: Schema.Types.UUID, default: true },
6
+ username: { type: String, required: true },
7
+ img: {
8
+ bucket: { type: String, required: true },
9
+ key: { type: String, required: true },
10
+ },
11
+ name: { type: String, required: true },
12
+ };
13
+
14
+ export default CustomerMinifiedSchema;
@@ -0,0 +1,14 @@
1
+ import { Schema } from "mongoose";
2
+ import CustomerMinifiedSchema from "./CustomerMinifiedSchema";
3
+
4
+ // 2. Create a Schema corresponding to the document interface.
5
+ const CustomerSchema = {
6
+ id: { type: Schema.Types.UUID, default: true },
7
+ minified: CustomerMinifiedSchema,
8
+ paid: { type: Boolean, default: false },
9
+ email: { type: String, required: true },
10
+ verified: { type: Boolean, default: false },
11
+ confirmed: { type: Boolean, default: false },
12
+ };
13
+
14
+ export default CustomerSchema;
@@ -0,0 +1,11 @@
1
+ import { Schema } from "mongoose";
2
+ import CustomerSchema from "./CustomerSchema";
3
+
4
+ // 2. Create a Schema corresponding to the document interface.
5
+ const NotiTypeSchema = {
6
+ id: { type: Schema.Types.UUID, default: true },
7
+ entity: CustomerSchema,
8
+ type: { type: String, required: true },
9
+ };
10
+
11
+ export default NotiTypeSchema;
@@ -0,0 +1,15 @@
1
+ import { Schema } from "mongoose";
2
+ import CustomerMinifiedSchema from "./CustomerMinifiedSchema";
3
+
4
+ // 2. Create a Schema corresponding to the document interface.
5
+ const NotificationSchema = {
6
+ id: { type: Schema.Types.UUID, default: true },
7
+ title: { type: String, required: true },
8
+ message: { type: String, required: true },
9
+ type: { type: String, required: true },
10
+ body: { type: String },
11
+ entityId: { type: String, required: true },
12
+ entityMinified: CustomerMinifiedSchema,
13
+ };
14
+
15
+ export default NotificationSchema;
@@ -0,0 +1,12 @@
1
+ import { Schema } from "mongoose";
2
+
3
+ const NotihubStatsHistorySchema = {
4
+ id: { type: Schema.Types.UUID, default: true },
5
+ entityId: { type: String, required: true },
6
+ notifications: { type: Number, required: true },
7
+ subscription: { type: Number, required: true },
8
+ views: { type: Number, required: true },
9
+ type: { type: String, required: true },
10
+ };
11
+
12
+ export default NotihubStatsHistorySchema;
@@ -0,0 +1,9 @@
1
+ import { Schema, model } from "mongoose";
2
+
3
+ // 2. Create a Schema corresponding to the document interface.
4
+ const NotificationSchema = {
5
+ notification: Notification,
6
+ views: { type: Number, default: 0 },
7
+ };
8
+
9
+ export default NotificationSchema;
@@ -0,0 +1,13 @@
1
+ import mongoose, { Schema } from "mongoose";
2
+ import CustomerSchema from "./CustomerSchema";
3
+ import UserSchema from "./UserSchema";
4
+
5
+ // 2. Create a Schema corresponding to the document interface.
6
+ const SubscriptionSchema = {
7
+ id: { type: Schema.Types.UUID, default: true },
8
+ subscriptionId: { type: String, required: true },
9
+ user: UserSchema,
10
+ entity: CustomerSchema,
11
+ };
12
+
13
+ export default SubscriptionSchema;
@@ -0,0 +1,7 @@
1
+ const SubscriptionSchema = {
2
+ userId: { type: String, required: true },
3
+ entityId: { type: String, required: true },
4
+ notiTypeId: { type: String, required: true },
5
+ };
6
+
7
+ export default SubscriptionSchema;
@@ -0,0 +1,11 @@
1
+ import { Schema } from "mongoose";
2
+
3
+ const UserSchema = {
4
+ id: { type: Schema.Types.UUID, default: true },
5
+ name: { type: String, required: true },
6
+ email: { type: String, required: true },
7
+ pushToken: { type: String, required: true },
8
+ signedIn: { type: Boolean, required: true, default: false },
9
+ };
10
+
11
+ export default UserSchema;
package/src/types.ts ADDED
@@ -0,0 +1,161 @@
1
+ // ----------------- Request Types ---------------------
2
+ export type CreateNotiRequestBody = {
3
+ subscriptionId: string;
4
+ userId: string;
5
+ title: string;
6
+ message: string;
7
+ type: string;
8
+ };
9
+
10
+ export type CreateSubscriptionRequestBody = {
11
+ subscriptionId: string;
12
+ type: string;
13
+ };
14
+
15
+ export type CreateUserRequestBody = {
16
+ name: string;
17
+ email: string;
18
+ token: string;
19
+ };
20
+
21
+ export type ICreateCustomerRequestBody = {
22
+ email: string;
23
+ username: string;
24
+ name: string;
25
+ };
26
+
27
+ export type ICreateNotiRequestBody = {};
28
+
29
+ // ----------------- NotiHub Types ---------------------
30
+
31
+ export type INotiHubCustomerMinified = {
32
+ _id: string;
33
+ name: string;
34
+ img: INotiHubImage;
35
+ username: string;
36
+ createdAt: string;
37
+ updatedAt: string;
38
+ };
39
+ export type INotiHubCustomer = {
40
+ _id: string;
41
+ name: string;
42
+ email: string;
43
+ minified: INotiHubCustomerMinified;
44
+ verified: boolean;
45
+ paid: boolean;
46
+ confirmed: boolean;
47
+ createdAt: string;
48
+ updatedAt: string;
49
+ };
50
+
51
+ export type INotiHubNotification = {
52
+ _id?: string;
53
+ title: string;
54
+ message: string;
55
+ type: string;
56
+ entityId: string;
57
+ entityMinified: INotiHubCustomerMinified;
58
+ body: string;
59
+ createdAt: string;
60
+ updatedAt: string;
61
+ };
62
+
63
+ export type INotiHubNotificationStats = {
64
+ _id?: string;
65
+ notification: INotiHubNotification;
66
+ views: number;
67
+ };
68
+
69
+ export type INotiHubUser = {
70
+ _id?: string;
71
+ pushToken: string;
72
+ name: string;
73
+ email: string;
74
+ subscriptions: number;
75
+ events: number;
76
+ };
77
+
78
+ export type INotiHubImage = {
79
+ bucket: string;
80
+ key: string;
81
+ };
82
+
83
+ export type INotiHubStats = {
84
+ entityRef: string;
85
+ entity: INotiHubCustomer;
86
+ subscription: number;
87
+ notifications: number;
88
+ views: number;
89
+ };
90
+
91
+ export type INotiHubStatsHistory = {
92
+ entityId: string;
93
+ type: "MONTH" | "YEAR";
94
+ subscription: number;
95
+ notifications: number;
96
+ views: number;
97
+ };
98
+
99
+ export type INotiType = {
100
+ _id?: string;
101
+ type: string;
102
+ entity: string;
103
+ createdAt: string;
104
+ updatedAt: string;
105
+ };
106
+
107
+ export type INotiTypeStats = {
108
+ _id?: string;
109
+ notiTypeId: string;
110
+ subscribed: number;
111
+ createdAt: string;
112
+ };
113
+
114
+ export type IUserSubscription = {
115
+ user: INotiHubUser;
116
+ entity: INotiHubCustomer;
117
+ subscriptionId: string;
118
+ type: "SUBSCRIBED" | "UNSUBSCRIBED";
119
+ createdAt: string;
120
+ updatedAt: string;
121
+ };
122
+
123
+ export type IUserSubscribeNotifier = {
124
+ userId: string;
125
+ entityId: string;
126
+ notiTypeId: string;
127
+ createdAt: string;
128
+ updatedAt: string;
129
+ };
130
+
131
+ export type INotiHubUserView = {
132
+ userId: string;
133
+ entityId: string;
134
+ notificationId: string;
135
+ createdAt: string;
136
+ };
137
+
138
+ export type INotiHubSubscription = {
139
+ _id?: string;
140
+ subscriptionId: string;
141
+ entity: INotiHubCustomer;
142
+ user: INotiHubUser;
143
+ type: "SUBSCRIBED" | "UNSUBSCRIBED";
144
+ createdAt: string;
145
+ updatedAt: string;
146
+ };
147
+
148
+ export type NotiHubTypes = {
149
+ INotiHubUserView: INotiHubUserView;
150
+ IUserSubscribeNotifier: IUserSubscribeNotifier;
151
+ IUserSubscription: IUserSubscription;
152
+ INotiHubUser: INotiHubUser;
153
+ INotiTypeStats: INotiTypeStats;
154
+ INotiHubImage: INotiHubImage;
155
+ INotiHubSubscription: INotiHubSubscription;
156
+ INotiHubNotificationStats: INotiHubNotificationStats;
157
+ INotiHubNotification: INotiHubNotification;
158
+ INotiHubCustomer: INotiHubCustomer;
159
+ INotiHubCustomerMinified: INotiHubCustomerMinified;
160
+ INotiHubStatsHistory: INotiHubStatsHistory;
161
+ };
@@ -0,0 +1,60 @@
1
+ const getDate = (dateStr: string) => {
2
+ const date = new Date(dateStr); // Convert seconds to milliseconds
3
+ const year = date.getFullYear();
4
+ const month = (date.getMonth() + 1).toString().padStart(2, "0"); // Months are zero-based
5
+ const day = date.getDate().toString().padStart(2, "0");
6
+
7
+ const formattedDate = `${month}-${day}-${year}`;
8
+
9
+ return formattedDate;
10
+ };
11
+
12
+ const getDateFormat = (dateStr: string) => {
13
+ const date = new Date(dateStr);
14
+ const now = new Date();
15
+ const seconds = Math.floor((now.getTime() - date.getTime()) / 1000);
16
+
17
+ let interval = seconds / 31536000;
18
+
19
+ if (interval > 1) {
20
+ return date.toLocaleDateString("en-US", {
21
+ year: "numeric",
22
+ month: "short",
23
+ day: "numeric",
24
+ });
25
+ }
26
+ interval = seconds / 2592000;
27
+ if (interval > 1) {
28
+ return date.toLocaleDateString("en-US", {
29
+ year: "numeric",
30
+ month: "short",
31
+ day: "numeric",
32
+ });
33
+ }
34
+ interval = seconds / 86400;
35
+ if (interval > 7) {
36
+ return date.toLocaleDateString("en-US", {
37
+ year: "numeric",
38
+ month: "short",
39
+ day: "numeric",
40
+ });
41
+ } else if (interval > 1) {
42
+ return Math.floor(interval) + "d ago";
43
+ }
44
+ interval = seconds / 3600;
45
+ if (interval > 1) {
46
+ return Math.floor(interval) + "h ago";
47
+ }
48
+ interval = seconds / 60;
49
+ if (interval > 1) {
50
+ return Math.floor(interval) + "m ago";
51
+ }
52
+ return Math.floor(seconds) + "s ago";
53
+ };
54
+
55
+ function addMonths(date: Date, months: number) {
56
+ date.setMonth(date.getMonth() + months);
57
+ return date;
58
+ }
59
+
60
+ export default { addMonths, getDate, getDateFormat };