18 lines
516 B
TypeScript
18 lines
516 B
TypeScript
export const baseUrl = "http://localhost:8080";
|
|
export const doorName = "test";
|
|
export const buzzerNumber = "6133163433";
|
|
export const key = "1234";
|
|
|
|
export const waitForService = async (url: string, timeout = 30000) => {
|
|
const start = Date.now();
|
|
|
|
while (Date.now() - start < timeout) {
|
|
try {
|
|
await fetch(url);
|
|
return true;
|
|
} catch (err) {
|
|
await new Promise(resolve => setTimeout(resolve, 1000));
|
|
}
|
|
}
|
|
throw new Error(`Service at ${url} did not start within ${timeout}ms`);
|
|
}; |