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