Skip to content

Commit e3ae670

Browse files
committed
refactor: remove server-mods as they are depricated
1 parent 6942613 commit e3ae670

File tree

6 files changed

+2
-138
lines changed

6 files changed

+2
-138
lines changed

config.json

+1-5
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,5 @@
1414
"host": "127.0.0.1",
1515
"port": 6380
1616
},
17-
"postgres": "postgres://viper:@127.0.0.1:5434/viper",
18-
"mod": {
19-
"dirPath": "mods",
20-
"configDirPath": "configs"
21-
}
17+
"postgres": "postgres://viper:@127.0.0.1:5434/viper"
2218
}

package.json

-2
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,6 @@
2424
"express": "^4.18.2",
2525
"http-proxy": "^1.18.1",
2626
"http-proxy-middleware": "^2.0.6",
27-
"jszip": "^3.10.1",
28-
"knockoutcity-mod-loader": "^1.0.0-alpha.15",
2927
"prisma": "^5.4.1",
3028
"redis": "^4.6.7"
3129
},

src/config.ts

+1-5
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,5 @@ export default {
3636
port: process.env.REDIS_PORT || config.redis.port,
3737
password: process.env.REDIS_PASSWORD || config.redis.password || undefined,
3838
},
39-
postgres: process.env.DATABASE_URL || config.postgres,
40-
mod: {
41-
dirPath: process.env.MOD_DIR_PATH || config.mod.dirPath,
42-
configDirPath: process.env.MOD_CONFIG_DIR_PATH || config.mod.configDirPath,
43-
},
39+
postgres: process.env.DATABASE_URL || config.postgres
4440
} satisfies config

src/index.ts

-57
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,6 @@ import { PrismaClient } from '@prisma/client'
88
import Logger from './logger.js'
99

1010
import { authError, authResponse, authErrorData } from './interfaces'
11-
import { EvaluationResult, ModEvaluator, ModLoader, OutGenerator } from 'knockoutcity-mod-loader';
12-
import { createZipFromFolder } from './ziputil';
13-
14-
import path from 'node:path';
15-
import os from 'node:os';
1611

1712
const log = new Logger();
1813

@@ -64,58 +59,6 @@ app.get('/stats/status', async (req, res) => {
6459
});
6560
});
6661

67-
const modLoader = new ModLoader({
68-
modDir: config.mod.dirPath,
69-
});
70-
71-
const createModZip = async (modPath: string): Promise<Buffer> => {
72-
const zip = await createZipFromFolder(modPath);
73-
return zip.generateAsync({ type: 'nodebuffer', compression: 'DEFLATE' });
74-
};
75-
76-
app.get('/mods/list', async (req, res) => {
77-
const mods = modLoader.loadModManifests();
78-
79-
return res.json(
80-
await Promise.all(
81-
mods
82-
.filter((mod) => mod.manifest.type === 'server-client')
83-
.map(async (mod) => ({
84-
name: mod.manifest.name,
85-
version: mod.manifest.version,
86-
}))
87-
)
88-
);
89-
});
90-
91-
app.get('/mods/download', async (req, res) => {
92-
const mods = modLoader.loadMods();
93-
const clientServerMods = mods.filter((mod) => mod.manifest.type === 'server-client');
94-
95-
if (clientServerMods.length === 0) {
96-
return res.status(400).send();
97-
}
98-
99-
const evaluationResults: EvaluationResult[] = [];
100-
for (const mod of clientServerMods) {
101-
const modEvaluator = new ModEvaluator(mod, { modsConfigDir: config.mod.configDirPath });
102-
evaluationResults.push(await modEvaluator.evaulate())
103-
}
104-
105-
const tempDirPath = path.join(os.tmpdir(), 'generated-mod-output');
106-
const outGenerator = new OutGenerator({ baseDir: tempDirPath});
107-
await outGenerator.generate(evaluationResults);
108-
109-
const zipBuffer = await createModZip(tempDirPath);
110-
return (
111-
res
112-
.header('Content-Disposition', `attachment; filename="mods.zip"`)
113-
.contentType('application/zip')
114-
.send(zipBuffer)
115-
);
116-
});
117-
118-
11962
app.use(async (req: express.Request, res: express.Response, next: express.NextFunction) => {
12063
log.info(`Request from ${req.ip} to ${req.url}`);
12164
res.set('X-Powered-By', 'KoCity Proxy');

src/interfaces.ts

-6
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,6 @@ export interface config {
3232
password?: string,
3333
},
3434
postgres: string,
35-
mod: {
36-
/** The path to the mods directory */
37-
dirPath: string,
38-
/** The path to the mods configuration directory */
39-
configDirPath: string,
40-
},
4135
}
4236

4337

src/ziputil.ts

-63
This file was deleted.

0 commit comments

Comments
 (0)