aboutsummaryrefslogtreecommitdiffstats
path: root/helpers/helpers.ts
blob: 3a16d18e405841a6edbeffd373996a0f8ab181bd (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
import fetch from "node-fetch";

export async function makeQuery(
  query: string,
  params: Array<string>
): Promise<string> {
  console.log("makeQuery");
  return await (
    await fetch("https://jopek.eu/maks/szkola/apkKli/fiaFiles/fia.php", {
      method: "POST",
      headers: {
        Accept: "application/json",
        "Content-Type": "application/json"
      },
      body: JSON.stringify({
        apiKey: process.env.API_KEY,
        stmt: query,
        params: params
      })
    })
  ).text();
}

export interface Colors {
  blue: number;
  red: number;
  green: number;
  yellow: number;
  0: number;
  1: number;
  2: number;
  3: number;
}

export const Color: Colors = {
  blue: 0,
  red: 1,
  green: 2,
  yellow: 3,
  0: 0,
  1: 1,
  2: 2,
  3: 3
};

export type tColors = typeof Color[keyof typeof Color];
export type Data = Array<{ id: any; color: tColors; name: string }>;
export interface fiaTable {
  id: number;
  data: Data;
  started: boolean;
}