redacted my info, into my database #1

Merged
botalex merged 21 commits from dev into main 2025-10-09 06:42:05 +02:00
3 changed files with 44 additions and 12 deletions
Showing only changes of commit fd1ef8612f - Show all commits

10
src/env.d.ts vendored
View file

@ -1,10 +0,0 @@
/// <reference types="vite/client" />
interface ImportMetaEnv {
readonly PUBLIC_URL_BASE: string;
readonly PUBLIC_POCKET_URL: string;
}
interface ImportMeta {
readonly env: ImportMetaEnv;
}

42
src/ts/EnvHandler.ts Normal file
View file

@ -0,0 +1,42 @@
// used to deal with .env things, but with this instead because nix
export let env = {
POCKETBASE_URL: "https://pocket.deprived.dev/",
DEV_POCKETBASE_URL: "https://dev.pocket.deprived.dev/",
};
export default env;
// Check if ?debug=1 or debug in localstorage is 1 or true
export function checkIfDev(): boolean {
if (typeof window === "undefined") return false;
try {
const params = new URL(window.location.href).searchParams;
const urlDebug = params.get("debug");
const ls = window.localStorage?.getItem("debug") ?? "";
const lsDebug = ls.toLowerCase();
const isUrlDebug = urlDebug === "1";
const isLocalDebug = lsDebug === "1" || lsDebug === "true";
return isUrlDebug || isLocalDebug;
} catch {
return false;
}
}
// Load overrides from localstorage
function loadOverrides() {
for (const [name, val] of Object.entries(env)) {
const envOverride = localStorage.getItem(name);
if (envOverride) {
env[name] = envOverride;
console.log("Env var +: " + name + "=" + val);
} else {
console.log("Env var loaded: " + name + "=" + val);
}
}
}
loadOverrides();

View file

@ -1,4 +1,5 @@
import { parseProfile, type Profile } from "./Profile";
import env from "@ts/EnvHandler";
class Redactor {
public unredactedProfile: Profile | undefined = undefined;
@ -23,7 +24,7 @@ class Redactor {
const unredactHash = hashResJson.response;
console.log('Trying unredact hash: "' + unredactHash + '"');
const url = `https://pocket.deprived.dev/api/files/redacted_content/${unredactHash}/redacted_cv_info_ha08bbn520.json`;
const url = `https://${env.POCKETBASE_URL}/api/files/redacted_content/${unredactHash}/redacted_cv_info_ha08bbn520.json`;
const res = await fetch(url, {
method: "GET",
@ -35,7 +36,6 @@ class Redactor {
return parseProfile(data);
}
// TS/JS
async t(unredactPath: string, fallback: string): Promise<string> {
try {
if (!this.unredactedProfile) await this.TryGetUnredacter();