5740774a46
This is the result of running `npm run format` which applies the Biome formatting rules. Rejoice!
33 lines
1.1 KiB
TypeScript
33 lines
1.1 KiB
TypeScript
import { IncomingMessage, ServerResponse } from "node:http";
|
|
import { ImageRouteService } from "@spt/services/mod/image/ImageRouteService";
|
|
import { HttpFileUtil } from "@spt/utils/HttpFileUtil";
|
|
import { VFS } from "@spt/utils/VFS";
|
|
import { inject, injectable } from "tsyringe";
|
|
|
|
@injectable()
|
|
export class ImageRouter {
|
|
constructor(
|
|
@inject("VFS") protected vfs: VFS,
|
|
@inject("ImageRouteService") protected imageRouteService: ImageRouteService,
|
|
@inject("HttpFileUtil") protected httpFileUtil: HttpFileUtil,
|
|
) {}
|
|
|
|
public addRoute(key: string, valueToAdd: string): void {
|
|
this.imageRouteService.addRoute(key, valueToAdd);
|
|
}
|
|
|
|
public sendImage(sessionID: string, req: IncomingMessage, resp: ServerResponse, body: any): void {
|
|
// remove file extension
|
|
const url = this.vfs.stripExtension(req.url);
|
|
|
|
// send image
|
|
if (this.imageRouteService.existsByKey(url)) {
|
|
this.httpFileUtil.sendFile(resp, this.imageRouteService.getByKey(url));
|
|
}
|
|
}
|
|
|
|
public getImage(): string {
|
|
return "IMAGE";
|
|
}
|
|
}
|