sync but probably in a broken state
Some checks failed
Rebuild signaller for deprived.dev to rebuild site / test_service (push) Failing after 15s
Some checks failed
Rebuild signaller for deprived.dev to rebuild site / test_service (push) Failing after 15s
This commit is contained in:
parent
4c1c0c600d
commit
fd1ef8612f
3 changed files with 44 additions and 12 deletions
42
src/ts/EnvHandler.ts
Normal file
42
src/ts/EnvHandler.ts
Normal 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();
|
||||
|
|
@ -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();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue