significant refactor
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
import PocketBase from 'pocketbase';
|
||||
import { createPlayersService } from './services/players';
|
||||
import { createTournamentsService } from './services/tournaments';
|
||||
import { createTeamsService } from './services/teams';
|
||||
import PocketBase from "pocketbase";
|
||||
import { createPlayersService } from "./services/players";
|
||||
import { createTournamentsService } from "./services/tournaments";
|
||||
import { createTeamsService } from "./services/teams";
|
||||
|
||||
class PocketBaseAdminClient {
|
||||
private pb: PocketBase;
|
||||
@@ -11,20 +11,20 @@ class PocketBaseAdminClient {
|
||||
this.pb = new PocketBase(import.meta.env.VITE_POCKETBASE_URL);
|
||||
|
||||
this.pb.beforeSend = (url, options) => {
|
||||
options.cache = 'no-store';
|
||||
options.cache = "no-store";
|
||||
options.headers = {
|
||||
...options.headers,
|
||||
'Cache-Control': 'no-cache, no-store, must-revalidate',
|
||||
'Pragma': 'no-cache',
|
||||
'Expires': '0'
|
||||
"Cache-Control": "no-cache, no-store, must-revalidate",
|
||||
Pragma: "no-cache",
|
||||
Expires: "0",
|
||||
};
|
||||
|
||||
|
||||
return { url, options };
|
||||
};
|
||||
this.pb.autoCancellation(false);
|
||||
|
||||
this.authPromise = this.authenticate();
|
||||
|
||||
|
||||
this.authPromise.then(() => {
|
||||
Object.assign(this, createPlayersService(this.pb));
|
||||
Object.assign(this, createTeamsService(this.pb));
|
||||
@@ -33,18 +33,20 @@ class PocketBaseAdminClient {
|
||||
}
|
||||
|
||||
private async authenticate() {
|
||||
await this.pb.collection("_superusers").authWithPassword(
|
||||
import.meta.env.VITE_POCKETBASE_ADMIN_EMAIL!,
|
||||
import.meta.env.VITE_POCKETBASE_ADMIN_PASSWORD!
|
||||
);
|
||||
await this.pb
|
||||
.collection("_superusers")
|
||||
.authWithPassword(
|
||||
import.meta.env.VITE_POCKETBASE_ADMIN_EMAIL!,
|
||||
import.meta.env.VITE_POCKETBASE_ADMIN_PASSWORD!
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
interface AdminClient extends
|
||||
PocketBaseAdminClient,
|
||||
ReturnType<typeof createPlayersService>,
|
||||
ReturnType<typeof createTeamsService>,
|
||||
ReturnType<typeof createTournamentsService> {
|
||||
interface AdminClient
|
||||
extends PocketBaseAdminClient,
|
||||
ReturnType<typeof createPlayersService>,
|
||||
ReturnType<typeof createTeamsService>,
|
||||
ReturnType<typeof createTournamentsService> {
|
||||
authPromise: Promise<void>;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user