Compare commits
2 Commits
c8814c3e2c
...
v1.0.46
| Author | SHA1 | Date | |
|---|---|---|---|
| 7bf37ba510 | |||
| 3c04b5db26 |
@@ -92,7 +92,7 @@ function buildDefaultServerUrl(): string {
|
|||||||
|
|
||||||
/** Blueprint for the built-in default endpoint. */
|
/** Blueprint for the built-in default endpoint. */
|
||||||
const DEFAULT_ENDPOINT: Omit<ServerEndpoint, 'id'> = {
|
const DEFAULT_ENDPOINT: Omit<ServerEndpoint, 'id'> = {
|
||||||
name: 'Local Server',
|
name: 'Default Server',
|
||||||
url: buildDefaultServerUrl(),
|
url: buildDefaultServerUrl(),
|
||||||
isActive: true,
|
isActive: true,
|
||||||
isDefault: true,
|
isDefault: true,
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
export const environment = {
|
export const environment = {
|
||||||
production: true,
|
production: true,
|
||||||
defaultServerUrl: 'https://tojusignal.azaaxin.com'
|
defaultServerUrl: 'https://signal.toju.app'
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -34,6 +34,8 @@ function Invoke-RoboCopyMirror {
|
|||||||
if ($LASTEXITCODE -gt 7) {
|
if ($LASTEXITCODE -gt 7) {
|
||||||
throw "robocopy failed from $Source to $Destination with exit code $LASTEXITCODE"
|
throw "robocopy failed from $Source to $Destination with exit code $LASTEXITCODE"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$global:LASTEXITCODE = 0
|
||||||
}
|
}
|
||||||
|
|
||||||
function Ensure-AppPool {
|
function Ensure-AppPool {
|
||||||
@@ -99,3 +101,5 @@ $deployments = @(
|
|||||||
foreach ($deployment in $deployments) {
|
foreach ($deployment in $deployments) {
|
||||||
Publish-IisSite @deployment
|
Publish-IisSite @deployment
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$global:LASTEXITCODE = 0
|
||||||
|
|||||||
@@ -55,6 +55,8 @@ const ARCHIVE_SUFFIXES = [
|
|||||||
'.7z',
|
'.7z',
|
||||||
'.rar'
|
'.rar'
|
||||||
];
|
];
|
||||||
|
const DIRECT_RELEASES_API_URL = 'https://git.azaaxin.com/api/v1/repos/myxelium/Toju/releases';
|
||||||
|
const PROXY_RELEASES_API_URL = '/api/releases';
|
||||||
|
|
||||||
function matchesAssetPattern(name: string, suffixes: string[], hints: string[] = []): boolean {
|
function matchesAssetPattern(name: string, suffixes: string[], hints: string[] = []): boolean {
|
||||||
if (suffixes.some((suffix) => name.endsWith(suffix))) {
|
if (suffixes.some((suffix) => name.endsWith(suffix))) {
|
||||||
@@ -205,15 +207,7 @@ export class ReleaseService {
|
|||||||
|
|
||||||
private async fetchReleasesInternal(): Promise<Release[]> {
|
private async fetchReleasesInternal(): Promise<Release[]> {
|
||||||
try {
|
try {
|
||||||
const response = await fetch('/api/releases', {
|
const data = await this.fetchReleasesFromAvailableEndpoints();
|
||||||
headers: { Accept: 'application/json' }
|
|
||||||
});
|
|
||||||
|
|
||||||
if (!response.ok) {
|
|
||||||
throw new Error(`HTTP ${response.status}`);
|
|
||||||
}
|
|
||||||
|
|
||||||
const data = await response.json();
|
|
||||||
|
|
||||||
this.cachedReleases = Array.isArray(data) ? data : [data];
|
this.cachedReleases = Array.isArray(data) ? data : [data];
|
||||||
|
|
||||||
@@ -226,4 +220,41 @@ export class ReleaseService {
|
|||||||
this.fetchPromise = null;
|
this.fetchPromise = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private async fetchReleasesFromAvailableEndpoints(): Promise<Release[] | Release> {
|
||||||
|
let lastError: unknown = null;
|
||||||
|
|
||||||
|
for (const endpoint of this.getReleaseEndpoints()) {
|
||||||
|
try {
|
||||||
|
const response = await fetch(endpoint, {
|
||||||
|
headers: { Accept: 'application/json' }
|
||||||
|
});
|
||||||
|
|
||||||
|
if (!response.ok) {
|
||||||
|
throw new Error(`HTTP ${response.status}`);
|
||||||
|
}
|
||||||
|
|
||||||
|
return await response.json();
|
||||||
|
} catch (error) {
|
||||||
|
lastError = error;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
throw lastError instanceof Error
|
||||||
|
? lastError
|
||||||
|
: new Error('Failed to fetch releases from all configured endpoints.');
|
||||||
|
}
|
||||||
|
|
||||||
|
private getReleaseEndpoints(): string[] {
|
||||||
|
if (!isPlatformBrowser(this.platformId)) {
|
||||||
|
return [PROXY_RELEASES_API_URL, DIRECT_RELEASES_API_URL];
|
||||||
|
}
|
||||||
|
|
||||||
|
const hostname = window.location.hostname;
|
||||||
|
const isLocalHost = hostname === 'localhost' || hostname === '127.0.0.1';
|
||||||
|
|
||||||
|
return isLocalHost
|
||||||
|
? [PROXY_RELEASES_API_URL, DIRECT_RELEASES_API_URL]
|
||||||
|
: [DIRECT_RELEASES_API_URL, PROXY_RELEASES_API_URL];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user