2022-06-08 22:08:43 +01:00
|
|
|
import { DependencyContainer } from "tsyringe";
|
2022-08-19 17:27:56 +01:00
|
|
|
import { IPreAkiLoadMod } from "@spt-aki/models/external/IPreAkiLoadMod";
|
2022-09-19 00:12:56 +01:00
|
|
|
import { DynamicRouterModService } from "@spt-aki/services/mod/dynamicRouter/DynamicRouterModService";
|
|
|
|
import { HttpResponseUtil } from "@spt-aki/utils/HttpResponseUtil";
|
2022-06-08 22:08:43 +01:00
|
|
|
|
2022-08-19 17:27:56 +01:00
|
|
|
class CWX_MasterKey implements IPreAkiLoadMod
|
2022-06-08 22:08:43 +01:00
|
|
|
{
|
2022-09-19 00:12:56 +01:00
|
|
|
|
|
|
|
private router: DynamicRouterModService;
|
|
|
|
private cfg;
|
|
|
|
private http: HttpResponseUtil;
|
|
|
|
|
2022-08-19 17:27:56 +01:00
|
|
|
public preAkiLoad(container: DependencyContainer): void
|
2022-09-19 00:12:56 +01:00
|
|
|
{
|
|
|
|
this.router = container.resolve<DynamicRouterModService>("DynamicRouterModService");
|
|
|
|
this.http = container.resolve<HttpResponseUtil>("HttpResponseUtil");
|
|
|
|
this.cfg = require("./config.json");
|
|
|
|
|
|
|
|
this.addRoute();
|
|
|
|
}
|
|
|
|
|
|
|
|
private addRoute() : void
|
|
|
|
{
|
|
|
|
this.router.registerDynamicRouter(
|
|
|
|
"MasterKey",
|
|
|
|
[
|
|
|
|
{
|
|
|
|
url: "/cwx/masterkey",
|
|
|
|
action: (url, info, sessionId, output) =>
|
|
|
|
{
|
|
|
|
return this.onRequestConfig();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
],
|
|
|
|
"MasterKey"
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
private onRequestConfig(): any
|
|
|
|
{
|
|
|
|
if (typeof this.cfg.keyId !== "string")
|
|
|
|
{
|
|
|
|
return this.http.noBody({ keyId: "5c1d0d6d86f7744bb2683e1f" });
|
|
|
|
}
|
|
|
|
|
|
|
|
return this.http.noBody({ keyId: this.cfg.keyId});
|
2022-06-08 22:08:43 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
module.exports = { mod: new CWX_MasterKey() }
|