Add admin accounts and streamlined header UI
This commit is contained in:
@@ -8,13 +8,10 @@ const autoBase = (() => {
|
||||
const basePath = metaBase || autoBase;
|
||||
const withBase = (path) => `${basePath}${path}`;
|
||||
|
||||
async function request(path, { method = "GET", body, adminKey } = {}) {
|
||||
async function request(path, { method = "GET", body } = {}) {
|
||||
const res = await fetch(withBase(path), {
|
||||
method,
|
||||
headers: {
|
||||
...defaultHeaders,
|
||||
...(adminKey ? { "X-Admin-Key": adminKey } : {})
|
||||
},
|
||||
headers: defaultHeaders,
|
||||
body: body ? JSON.stringify(body) : undefined,
|
||||
});
|
||||
|
||||
@@ -34,7 +31,6 @@ async function request(path, { method = "GET", body, adminKey } = {}) {
|
||||
export const api = {
|
||||
state: () => request("/api/state"),
|
||||
me: () => request("/api/me"),
|
||||
setName: (name) => request("/api/me/name", { method: "POST", body: { name } }),
|
||||
register: (payload) => request("/api/auth/register", { method: "POST", body: payload }),
|
||||
login: (payload) => request("/api/auth/login", { method: "POST", body: payload }),
|
||||
logout: () => request("/api/auth/logout", { method: "POST" }),
|
||||
@@ -51,7 +47,7 @@ export const api = {
|
||||
};
|
||||
|
||||
export const adminApi = {
|
||||
setPhase: (phase, adminKey) => request("/api/admin/phase", { method: "POST", body: { phase }, adminKey }),
|
||||
reset: (adminKey) => request("/api/admin/reset", { method: "POST", adminKey }),
|
||||
factoryReset: (adminKey) => request("/api/admin/factory-reset", { method: "POST", adminKey }),
|
||||
setPhase: (phase) => request("/api/admin/phase", { method: "POST", body: { phase } }),
|
||||
reset: () => request("/api/admin/reset", { method: "POST" }),
|
||||
factoryReset: () => request("/api/admin/factory-reset", { method: "POST" }),
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user