@prestizni-software/server-dem 0.2.1 → 0.2.2
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.
- package/CHANGELOG.md +2 -0
- package/package.json +1 -1
- package/server.ts +13 -116
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
|
|
4
4
|
|
|
5
|
+
### [0.2.2](https://github.com/Prestizni-Software/server-dem/compare/v0.2.1...v0.2.2) (2025-11-04)
|
|
6
|
+
|
|
5
7
|
### [0.2.1](https://github.com/Prestizni-Software/server-dem/compare/v0.1.25...v0.2.1) (2025-11-04)
|
|
6
8
|
|
|
7
9
|
### 0.1.25 (2025-11-04)
|
package/package.json
CHANGED
package/server.ts
CHANGED
|
@@ -1,116 +1,13 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
enum Statuses {
|
|
15
|
-
Status1 = "Status1",
|
|
16
|
-
Status2 = "Banana",
|
|
17
|
-
}
|
|
18
|
-
class Test2 {
|
|
19
|
-
@classProp public _id!: Types.ObjectId;
|
|
20
|
-
@classProp public login!: string;
|
|
21
|
-
@classProp public loggers2!: LoggersType;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
export class Test {
|
|
25
|
-
@classProp public _id!: Types.ObjectId;
|
|
26
|
-
@classProp public login!: string[];
|
|
27
|
-
@classProp public loggers2!: LoggersType;
|
|
28
|
-
@classProp public status!: Statuses;
|
|
29
|
-
|
|
30
|
-
@classProp @classRef @prop() public test2!: Ref<Test2>;
|
|
31
|
-
|
|
32
|
-
@classProp @classRef @prop() public test3?: Ref<Test2>;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
// ---------------------- Setup CLI ----------------------
|
|
36
|
-
const rl = readline.createInterface({
|
|
37
|
-
input: process.stdin,
|
|
38
|
-
output: process.stdout,
|
|
39
|
-
});
|
|
40
|
-
|
|
41
|
-
// ---------------------- Loggers ----------------------
|
|
42
|
-
const loggers: LoggersType = {
|
|
43
|
-
info: console.log,
|
|
44
|
-
debug: console.debug,
|
|
45
|
-
error: console.error,
|
|
46
|
-
warn: console.warn,
|
|
47
|
-
};
|
|
48
|
-
|
|
49
|
-
// ---------------------- Start Server ----------------------
|
|
50
|
-
const start = async () => {
|
|
51
|
-
console.log("📡 Connecting to MongoDB...");
|
|
52
|
-
await mongoose.connect("mongodb://localhost:27017");
|
|
53
|
-
console.log("✅ Connected to MongoDB");
|
|
54
|
-
|
|
55
|
-
const TestModel = getModelForClass(Test);
|
|
56
|
-
const Test2Model = getModelForClass(Test2);
|
|
57
|
-
|
|
58
|
-
// ---------------------- Socket.IO ----------------------
|
|
59
|
-
const httpServer = createServer();
|
|
60
|
-
const io = new Server(httpServer, { cors: { origin: "*" } });
|
|
61
|
-
|
|
62
|
-
httpServer.listen(3000, () => {
|
|
63
|
-
console.log("📡 Socket.IO server running on port 3000");
|
|
64
|
-
});
|
|
65
|
-
|
|
66
|
-
// ---------------------- Wrap DB entries ----------------------
|
|
67
|
-
|
|
68
|
-
const classers = await AUSManagerFactory(
|
|
69
|
-
{
|
|
70
|
-
Test: {
|
|
71
|
-
model: TestModel,
|
|
72
|
-
class: Test,
|
|
73
|
-
options: {
|
|
74
|
-
accessDefinitions: {
|
|
75
|
-
status: {},
|
|
76
|
-
"test3.loggers2.warn": {},
|
|
77
|
-
},
|
|
78
|
-
autoStatusDefinitions: createAutoStatusDefinitions({
|
|
79
|
-
class: Test,
|
|
80
|
-
statusProperty: "status",
|
|
81
|
-
statusEnum: Statuses,
|
|
82
|
-
definitions: {
|
|
83
|
-
Status1: {},
|
|
84
|
-
Status2:{}
|
|
85
|
-
},
|
|
86
|
-
}),
|
|
87
|
-
},
|
|
88
|
-
},
|
|
89
|
-
Test2: {
|
|
90
|
-
model: Test2Model,
|
|
91
|
-
class: Test2,
|
|
92
|
-
},
|
|
93
|
-
},
|
|
94
|
-
loggers,
|
|
95
|
-
io
|
|
96
|
-
);
|
|
97
|
-
|
|
98
|
-
const testObject = classers.Test.getObject("68c9f23872cff1778cb1abe2");
|
|
99
|
-
await testObject?.setValue("test2.loggers2", loggers);
|
|
100
|
-
testObject?.test2.loggers2.info("test");
|
|
101
|
-
await testObject?.setValue("test2.loggers2.info", console.error);
|
|
102
|
-
testObject?.test2.loggers2.info("test");
|
|
103
|
-
|
|
104
|
-
// ---------------------- Handle Socket Connections ----------------------
|
|
105
|
-
io.on("connection", async (socket) => {
|
|
106
|
-
console.log(`🔌 Client connected: ${socket.id}`);
|
|
107
|
-
for (const classer of Object.values(classers)) {
|
|
108
|
-
classer.registerSocket(socket);
|
|
109
|
-
}
|
|
110
|
-
// Client disconnect
|
|
111
|
-
socket.on("disconnect", () => {
|
|
112
|
-
console.log(`❌ Client disconnected: ${socket.id}`);
|
|
113
|
-
});
|
|
114
|
-
});
|
|
115
|
-
};
|
|
116
|
-
start();
|
|
1
|
+
import * as AutoUpdateServerManagerClass from "./AutoUpdateServerManagerClass.js";
|
|
2
|
+
import * as AutoUpdateManagerClass from "./AutoUpdateManagerClass.js";
|
|
3
|
+
import * as AutoUpdatedClientObjectClass from "./AutoUpdatedClientObjectClass.js";
|
|
4
|
+
import * as AutoUpdatedServerObjectClass from "./AutoUpdatedServerObjectClass.js";
|
|
5
|
+
import * as CommonTypes from "./CommonTypes.js";
|
|
6
|
+
|
|
7
|
+
module.exports = {
|
|
8
|
+
AutoUpdateServerManagerClass,
|
|
9
|
+
AutoUpdateManagerClass,
|
|
10
|
+
AutoUpdatedClientObjectClass,
|
|
11
|
+
AutoUpdatedServerObjectClass,
|
|
12
|
+
CommonTypes,
|
|
13
|
+
};
|