Handle all bundles regarless of extension on BundleSerializer

This commit is contained in:
TheSparta 2024-05-09 15:22:10 +01:00
parent a2f6d8b9bb
commit 3b0ee75d7f
3 changed files with 8 additions and 5 deletions

View File

@ -56,8 +56,7 @@ export class BundleLoader
public addBundles(modpath: string): void public addBundles(modpath: string): void
{ {
const bundleManifestArr const bundleManifestArr = this.jsonUtil.deserialize<BundleManifest>(this.vfs.readFile(`${modpath}bundles.json`)).manifest;
= this.jsonUtil.deserialize<BundleManifest>(this.vfs.readFile(`${modpath}bundles.json`)).manifest;
for (const bundleManifest of bundleManifestArr) for (const bundleManifest of bundleManifestArr)
{ {

View File

@ -8,7 +8,7 @@ export class BundleDynamicRouter extends DynamicRouter
constructor(@inject("BundleCallbacks") protected bundleCallbacks: BundleCallbacks) constructor(@inject("BundleCallbacks") protected bundleCallbacks: BundleCallbacks)
{ {
super([ super([
new RouteAction(".bundle", (url: string, info: any, sessionID: string, output: string): any => new RouteAction("/files/bundle", (url: string, info: any, sessionID: string, output: string): any =>
{ {
return this.bundleCallbacks.getBundle(url, info, sessionID); return this.bundleCallbacks.getBundle(url, info, sessionID);
}), }),

View File

@ -19,10 +19,14 @@ export class BundleSerializer extends Serializer
public override serialize(sessionID: string, req: IncomingMessage, resp: ServerResponse, body: any): void public override serialize(sessionID: string, req: IncomingMessage, resp: ServerResponse, body: any): void
{ {
this.logger.info(`[BUNDLE]: ${req.url}`);
const key = decodeURI(req.url.split("/bundle/")[1]); const key = decodeURI(req.url.split("/bundle/")[1]);
const bundle = this.bundleLoader.getBundle(key); const bundle = this.bundleLoader.getBundle(key);
if (!bundle)
{
return;
}
this.logger.info(`[BUNDLE]: ${req.url}`);
this.httpFileUtil.sendFile(resp, `${bundle.modpath}/bundles/${bundle.filename}`); this.httpFileUtil.sendFile(resp, `${bundle.modpath}/bundles/${bundle.filename}`);
} }