Skip to content

Commit

Permalink
Migrating to self hosted server
Browse files Browse the repository at this point in the history
  • Loading branch information
LyonSyonII committed Nov 24, 2023
1 parent e5bdd31 commit 72046b9
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 7 deletions.
4 changes: 3 additions & 1 deletion frontend/src/components/CodeBlock.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,10 @@
// Wait for the editor to update `value`
await new Promise((resolve) => setTimeout(resolve, 100));
const code = `fn main() { \n${setup.replace("__VALUE__", value)}\n }`;
playground_response = await evaluate(value, setup, lang, errorMsg);
playground_response = await evaluate(code, lang, errorMsg);
running = false;
};
</script>
Expand Down
8 changes: 2 additions & 6 deletions frontend/src/utils/evaluateCode.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import { translation, type Langs } from "@i18n/CodeBlock";

export async function evaluate(value: string, setup: string, lang: Langs, errorMsg?: string): Promise<string> {
export async function evaluate(code: string, lang: Langs, errorMsg?: string): Promise<string> {
const error = errorMsg || translation(lang).error;
const code = value.replaceAll("__VALUE__", setup);

return Promise.race([
server(code, error),
Expand All @@ -16,10 +15,7 @@ async function server(code: string, error: string): Promise<string> {
code
};

// TODO: Does not work
const auth = process.env.AUTH;
console.log({auth});

// TODO: Auth env var is not possible in the browser
return fetch("https://rust-quest.garriga.dev/evaluate.json", {
headers: {
"Content-Type": "application/json",
Expand Down

0 comments on commit 72046b9

Please sign in to comment.