Skip to content

Commit

Permalink
feat(backend): add config for backend urls where ast is sent
Browse files Browse the repository at this point in the history
  • Loading branch information
MatsJohansen87 committed Jun 6, 2024
1 parent 2172423 commit 547df28
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -156,11 +156,31 @@
backend.send(cql, controller, measures);
});
options?.customAstBackends?.forEach((customAstBackendUrl: string) => {
customBackendCallWithAst(ast, customAstBackendUrl);
});
emitEvent(ast);
queryModified.set(false);
};
const customBackendCallWithAst = (ast: AstTopLayer, url: string): void => {
fetch(url, {
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify(ast),
})
.then((response) => response.json())
.then((data) => {
updateResponseStore(data);
})
.catch((error) => {
console.error("Error:", error);
});
};
interface QueryEvent extends Event {
detail: {
ast: AstTopLayer;
Expand Down
5 changes: 3 additions & 2 deletions packages/lib/src/types/backend.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,9 @@ export type BlazeOption = {
};

export type BackendOptions = {
spots: SpotOption[];
blazes: BlazeOption[];
spots?: SpotOption[];
blazes?: BlazeOption[];
customAstBackends?: string[];
};

export interface QueryEvent extends Event {
Expand Down

0 comments on commit 547df28

Please sign in to comment.