|
@@ -2,7 +2,8 @@ import { createHash, type BinaryToTextEncoding } from "node:crypto";
|
|
import { Response } from "express";
|
|
import { Response } from "express";
|
|
import { parse as jsonToXml } from "js2xmlparser";
|
|
import { parse as jsonToXml } from "js2xmlparser";
|
|
import type { Stringifiable } from "svcorelib";
|
|
import type { Stringifiable } from "svcorelib";
|
|
-import { ResponseType } from "./types.js";
|
|
|
|
|
|
+import { verMajor } from "@src/constants.js";
|
|
|
|
+import type { ResponseType } from "@src/types.js";
|
|
|
|
|
|
/** Checks if the value of a passed URL parameter is a string with length > 0 */
|
|
/** Checks if the value of a passed URL parameter is a string with length > 0 */
|
|
export function paramValid(val: unknown): val is string {
|
|
export function paramValid(val: unknown): val is string {
|
|
@@ -72,6 +73,10 @@ export function respond(res: Response, type: ResponseType | number, data: String
|
|
res.status(statusCode).send(finalData);
|
|
res.status(statusCode).send(finalData);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+export function redirectToDocs(res: Response) {
|
|
|
|
+ res.redirect(`/v${verMajor}/docs/`);
|
|
|
|
+}
|
|
|
|
+
|
|
/** Hashes a string using SHA-512, encoded as "hex" by default */
|
|
/** Hashes a string using SHA-512, encoded as "hex" by default */
|
|
export function hashStr(str: string, encoding: BinaryToTextEncoding = "hex"): Promise<string> {
|
|
export function hashStr(str: string, encoding: BinaryToTextEncoding = "hex"): Promise<string> {
|
|
return new Promise((resolve, reject) => {
|
|
return new Promise((resolve, reject) => {
|