Update example
This commit is contained in:
parent
425cd38446
commit
5c84de4f1a
@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "RouterHooks",
|
||||
"version": "1.0.0",
|
||||
"akiVersion": "~3.9",
|
||||
"sptVersion": "~3.9",
|
||||
"loadBefore": [],
|
||||
"loadAfter": [],
|
||||
"incompatibilities": [],
|
||||
|
@ -1,13 +1,13 @@
|
||||
import { DependencyContainer } from "tsyringe";
|
||||
|
||||
import type { IPreAkiLoadMod } from "@spt-aki/models/external/IPreAkiLoadMod";
|
||||
import type { ILogger } from "@spt-aki/models/spt/utils/ILogger";
|
||||
import type {DynamicRouterModService} from "@spt-aki/services/mod/dynamicRouter/DynamicRouterModService";
|
||||
import type {StaticRouterModService} from "@spt-aki/services/mod/staticRouter/StaticRouterModService";
|
||||
import type { IPreSptLoadMod } from "@spt/models/external/IPreSptLoadMod";
|
||||
import type { ILogger } from "@spt/models/spt/utils/ILogger";
|
||||
import type {DynamicRouterModService} from "@spt/services/mod/dynamicRouter/DynamicRouterModService";
|
||||
import type {StaticRouterModService} from "@spt/services/mod/staticRouter/StaticRouterModService";
|
||||
|
||||
class Mod implements IPreAkiLoadMod
|
||||
class Mod implements IPreSptLoadMod
|
||||
{
|
||||
public preAkiLoad(container: DependencyContainer): void {
|
||||
public preSptLoad(container: DependencyContainer): void {
|
||||
const logger = container.resolve<ILogger>("WinstonLogger");
|
||||
const dynamicRouterModService = container.resolve<DynamicRouterModService>("DynamicRouterModService");
|
||||
const staticRouterModService = container.resolve<StaticRouterModService>("StaticRouterModService");
|
||||
@ -18,7 +18,7 @@ class Mod implements IPreAkiLoadMod
|
||||
[
|
||||
{
|
||||
url: "/my-dynamic-mod/",
|
||||
action: (url, info, sessionId, output) =>
|
||||
action: async (url, info, sessionId, output) =>
|
||||
{
|
||||
logger.info("Custom dynamic route hit");
|
||||
return JSON.stringify({response: "OK"});
|
||||
@ -34,7 +34,7 @@ class Mod implements IPreAkiLoadMod
|
||||
[
|
||||
{
|
||||
url: "/my-static-route-mod/",
|
||||
action: (url, info, sessionId, output) =>
|
||||
action: async (url, info, sessionId, output) =>
|
||||
{
|
||||
logger.info("Custom static route hit");
|
||||
return JSON.stringify({response: "OK"});
|
||||
@ -44,36 +44,36 @@ class Mod implements IPreAkiLoadMod
|
||||
"custom-static-my-mod"
|
||||
);
|
||||
|
||||
// Hook up to existing AKI dynamic route
|
||||
// Hook up to existing Spt dynamic route
|
||||
dynamicRouterModService.registerDynamicRouter(
|
||||
"DynamicRoutePeekingAki",
|
||||
"DynamicRoutePeekingSpt",
|
||||
[
|
||||
{
|
||||
url: "/client/menu/locale/",
|
||||
action: (url, info, sessionId, output) =>
|
||||
action: async (url, info, sessionId, output) =>
|
||||
{
|
||||
logger.info("/client/menu/locale/ data was: " + JSON.stringify(output));
|
||||
return output;
|
||||
}
|
||||
}
|
||||
],
|
||||
"aki"
|
||||
"spt"
|
||||
);
|
||||
|
||||
// Hook up to existing AKI static route
|
||||
// Hook up to existing SPT static route
|
||||
staticRouterModService.registerStaticRouter(
|
||||
"StaticRoutePeekingAki",
|
||||
"StaticRoutePeekingSpt",
|
||||
[
|
||||
{
|
||||
url: "/launcher/ping",
|
||||
action: (url, info, sessionId, output) =>
|
||||
action: async (url, info, sessionId, output) =>
|
||||
{
|
||||
logger.info("/launcher/ping data was: " + JSON.stringify(output));
|
||||
return output;
|
||||
}
|
||||
}
|
||||
],
|
||||
"aki"
|
||||
"spt"
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -11,8 +11,14 @@
|
||||
"resolveJsonModule": true,
|
||||
"outDir": "tmp",
|
||||
"paths": {
|
||||
"@spt-aki/*": ["./types/*"],
|
||||
"@spt/*": [
|
||||
"./types/*"
|
||||
],
|
||||
},
|
||||
},
|
||||
"exclude": ["node_modules", "dist", "tmp"],
|
||||
"exclude": [
|
||||
"node_modules",
|
||||
"dist",
|
||||
"tmp"
|
||||
],
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user