MCPcopy Create free account
hub / github.com/MCSManager/MCSManager / main

Function main

panel/src/app.ts:96–234  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

94});
95
96async function main() {
97 // load global configuration file
98 initSystemConfig();
99
100 if (systemConfig && systemConfig?.redisUrl?.length != 0) {
101 await RedisStorage.initialize(systemConfig.redisUrl);
102 Storage.setStorageType(Storage.TYPE.REDIS);
103 }
104
105 initVersionManager();
106 const VERSION = getVersion();
107
108 console.log(`______ _______________________ ___
109___ |/ /_ ____/_ ___/__ |/ /_____ _____________ _______ _____________
110__ /|_/ /_ / _____ \\__ /|_/ /_ __ \`/_ __ \\ __ \`/_ __ \`/ _ \\_ ___/
111_ / / / / /___ ____/ /_ / / / / /_/ /_ / / / /_/ /_ /_/ // __/ /
112/_/ /_/ \\____/ /____/ /_/ /_/ \\__,_/ /_/ /_/\\__,_/ _\\__, / \\___//_/
113 /____/
114
115 + Copyright ${new Date().getFullYear()} MCSManager Dev <https://github.com/MCSManager>
116 + Version ${VERSION}
117`);
118
119 // Detect whether the configuration file is from an older version and update it if so.
120 versionAdapter.detectConfig();
121
122 checkBusinessMode();
123
124 // Initialize services
125 await SystemUser.initialize();
126 await SystemRemoteService.initialize();
127
128 const app = new Koa({
129 proxy: systemConfig?.reverseProxyMode || false,
130 proxyIpHeader: systemConfig?.reverseProxyHeader || "X-Real-IP"
131 });
132
133 // Listen for Koa errors
134 app.on("error", (error) => {
135 // Block all Koa framework level events
136 // When Koa is attacked by a short connection flood, it is easy for error messages to swipe the screen, which may indirectly affect the operation of some applications
137 });
138
139 app.use(preCheckMiddleware);
140 app.use(
141 koaBody({
142 multipart: true,
143 parsedMethods: [
144 HttpMethodEnum.GET,
145 HttpMethodEnum.PUT,
146 HttpMethodEnum.POST,
147 HttpMethodEnum.DELETE
148 ],
149 formidable: {
150 maxFileSize: 1024 * 1024 * 500,
151 maxFiles: 1
152 },
153 jsonLimit: "10mb",

Callers 1

app.tsFile · 0.70

Calls 14

initSystemConfigFunction · 0.90
initVersionManagerFunction · 0.90
getVersionFunction · 0.90
checkBusinessModeFunction · 0.90
mountRoutersFunction · 0.90
compressFunction · 0.85
setupHttpFunction · 0.85
setStorageTypeMethod · 0.80
logMethod · 0.80
onMethod · 0.80
useMethod · 0.80
errorMethod · 0.80

Tested by

no test coverage detected