@@ -8,11 +8,6 @@ import { PrismaClient } from '@prisma/client'
8
8
import Logger from './logger.js'
9
9
10
10
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' ;
16
11
17
12
const log = new Logger ( ) ;
18
13
@@ -64,58 +59,6 @@ app.get('/stats/status', async (req, res) => {
64
59
} ) ;
65
60
} ) ;
66
61
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
-
119
62
app . use ( async ( req : express . Request , res : express . Response , next : express . NextFunction ) => {
120
63
log . info ( `Request from ${ req . ip } to ${ req . url } ` ) ;
121
64
res . set ( 'X-Powered-By' , 'KoCity Proxy' ) ;
0 commit comments