From 5c84de4f1a757ba2b87c874f8d320a97797704b5 Mon Sep 17 00:00:00 2001 From: Dev Date: Sat, 6 Jul 2024 22:02:33 +0100 Subject: [PATCH] Update example --- TypeScript/9RouterHooks/package.json | 4 ++-- TypeScript/9RouterHooks/src/mod.ts | 32 +++++++++++++-------------- TypeScript/9RouterHooks/tsconfig.json | 12 +++++++--- 3 files changed, 27 insertions(+), 21 deletions(-) diff --git a/TypeScript/9RouterHooks/package.json b/TypeScript/9RouterHooks/package.json index bf2f3c7..8911d49 100644 --- a/TypeScript/9RouterHooks/package.json +++ b/TypeScript/9RouterHooks/package.json @@ -1,7 +1,7 @@ { "name": "RouterHooks", "version": "1.0.0", - "akiVersion": "~3.9", + "sptVersion": "~3.9", "loadBefore": [], "loadAfter": [], "incompatibilities": [], @@ -27,4 +27,4 @@ "author": "Chomp", "contributors": [], "license": "MIT" -} +} \ No newline at end of file diff --git a/TypeScript/9RouterHooks/src/mod.ts b/TypeScript/9RouterHooks/src/mod.ts index 36ccde9..fb8ae61 100644 --- a/TypeScript/9RouterHooks/src/mod.ts +++ b/TypeScript/9RouterHooks/src/mod.ts @@ -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("WinstonLogger"); const dynamicRouterModService = container.resolve("DynamicRouterModService"); const staticRouterModService = container.resolve("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" ); } } diff --git a/TypeScript/9RouterHooks/tsconfig.json b/TypeScript/9RouterHooks/tsconfig.json index c5ca53f..1e0b2ca 100644 --- a/TypeScript/9RouterHooks/tsconfig.json +++ b/TypeScript/9RouterHooks/tsconfig.json @@ -11,8 +11,14 @@ "resolveJsonModule": true, "outDir": "tmp", "paths": { - "@spt-aki/*": ["./types/*"], + "@spt/*": [ + "./types/*" + ], }, }, - "exclude": ["node_modules", "dist", "tmp"], -} + "exclude": [ + "node_modules", + "dist", + "tmp" + ], +} \ No newline at end of file