new things.

This commit is contained in:
2025-09-12 20:45:48 -04:00
parent c2eb111291
commit 5934f1a91c
11 changed files with 43 additions and 13 deletions

View File

@@ -7,6 +7,7 @@ import Server from "../server/server.ts";
import { TokenFormat } from "../server/platforms/types.ts";
import { HTTPStatus, httpStatusText } from "@oneday/http-status";
import { ContentfulStatusCode } from "@hono/hono/utils/http-status";
import { env } from "../env.ts";
const log = new Logging("APIUtils");
@@ -33,7 +34,7 @@ const authHeaderSchema = z.string().transform((arg, ctx) => {
return split[1];
});
export async function authenticate(c: Context<HonoEnv>, nxt: Next) {
const secret = Deno.env.get('SECRET');
const secret = env["SECRET"];
if (!secret) return c.json(genericResponse(false, "Internal Server Error"), 500);
const authHeader = authHeaderSchema.safeParse(c.req.header('Authorization'));

View File

@@ -1,13 +1,16 @@
import Logging from "@proxnet/undead-logging";
import { Hono } from "@hono/hono";
import path from "node:path";
import process from "node:process";
import { HonoEnv, RouteImport } from "./types.ts";
import { RootPath } from "./path.ts";
const log = new Logging("RouteImport");
const debug = false;
export async function routeImporter(hono: Hono<HonoEnv>, prefix: string, paths: string[]) {
const items = await importer<RouteImport>('route', prefix, paths);
const p = `${RootPath.replaceAll('\\', '/')}${prefix}`;
if (debug) log.d(`Importing from "${p}"`);
const items = await importer<RouteImport>('route', p, paths);
for (const route of items) hono.route(route.path, route.app);
}
@@ -17,7 +20,7 @@ export async function importer<T>(importKey: string, p: string, paths: string[])
for (const pathStr of paths) {
const importPath = path.join(process.cwd(), p, pathStr);
const importPath = `${p}${pathStr}/`;
if (debug) log.d(`'${importKey}' found ${importPath}`);
for await (const localPath of Deno.readDir(importPath)) {

View File

@@ -1,3 +1,9 @@
import { platform } from "node:process";
import Logging, { TimeFormat } from "@proxnet/undead-logging";
export const RootPath = Deno.mainModule.substring(platform == 'win32' ? 8 : 7, Deno.mainModule.length - 11);
const log = new Logging("Path");
export const RootPath = Deno.mainModule.substring(platform == 'win32' ? 8 : 7, Deno.mainModule.length - 11);
log.timeFormat = TimeFormat.Unix;
log.i(`RootPath: ${RootPath}`);

View File

@@ -18,10 +18,11 @@ along with this program. If not, see <https://www.gnu.org/licenses/>. */
import Logging from "@proxnet/undead-logging";
import { SteamAuth, SteamAuthResult, SteamAuthRes } from "./SteamAuthTypes.ts";
import { SteamPlayer } from "./SteamCommonTypes.ts";
import { env } from "../../env.ts";
const log = new Logging("Steam");
const steamkey = Deno.env.get("STEAMKEY");
const steamkey = env["STEAMKEY"];
function buildSteamUrl(steaminterface: string, endpoint: string) {
return `https://api.steampowered.com/${steaminterface}/${endpoint}`;