mirror of
https://github.com/KevinMidboe/immich.git
synced 2026-01-13 20:55:54 +00:00
Remove VITE_SERVER_ENDPOINT dependency (#428)
* Move backend api to its own instance * Remove external fetch hook * Added endpoint for album * Added endpoint for admin page * Make request directly to immich-server * Refactor unsued code
This commit is contained in:
1
web/src/routes/data/README.md
Normal file
1
web/src/routes/data/README.md
Normal file
@@ -0,0 +1 @@
|
||||
This directory contain SSR endpoints to user serverApi instance to make request directly to DNS
|
||||
18
web/src/routes/data/album/get-album-info.ts
Normal file
18
web/src/routes/data/album/get-album-info.ts
Normal file
@@ -0,0 +1,18 @@
|
||||
import { AlbumResponseDto, serverApi } from '@api';
|
||||
import type { RequestEvent, RequestHandlerOutput } from '@sveltejs/kit';
|
||||
|
||||
export const GET = async ({
|
||||
url
|
||||
}: RequestEvent): Promise<RequestHandlerOutput<AlbumResponseDto>> => {
|
||||
try {
|
||||
const albumId = url.searchParams.get('albumId') || '';
|
||||
const { data } = await serverApi.albumApi.getAlbumInfo(albumId);
|
||||
return {
|
||||
body: data
|
||||
};
|
||||
} catch {
|
||||
return {
|
||||
status: 500
|
||||
};
|
||||
}
|
||||
};
|
||||
18
web/src/routes/data/album/get-all-albums.ts
Normal file
18
web/src/routes/data/album/get-all-albums.ts
Normal file
@@ -0,0 +1,18 @@
|
||||
import { AlbumResponseDto, serverApi } from '@api';
|
||||
import type { RequestEvent, RequestHandler, RequestHandlerOutput } from '@sveltejs/kit';
|
||||
|
||||
export const GET = async ({
|
||||
url
|
||||
}: RequestEvent): Promise<RequestHandlerOutput<AlbumResponseDto[]>> => {
|
||||
try {
|
||||
const isShared = url.searchParams.get('isShared') === 'true' || undefined;
|
||||
const { data } = await serverApi.albumApi.getAllAlbums(isShared);
|
||||
return {
|
||||
body: data
|
||||
};
|
||||
} catch {
|
||||
return {
|
||||
status: 500
|
||||
};
|
||||
}
|
||||
};
|
||||
15
web/src/routes/data/asset/get-all-assets.ts
Normal file
15
web/src/routes/data/asset/get-all-assets.ts
Normal file
@@ -0,0 +1,15 @@
|
||||
import { AssetResponseDto, serverApi } from '@api';
|
||||
import type { RequestHandlerOutput } from '@sveltejs/kit';
|
||||
|
||||
export const GET = async (): Promise<RequestHandlerOutput<AssetResponseDto[]>> => {
|
||||
try {
|
||||
const { data } = await serverApi.assetApi.getAllAssets();
|
||||
return {
|
||||
body: data
|
||||
};
|
||||
} catch {
|
||||
return {
|
||||
status: 500
|
||||
};
|
||||
}
|
||||
};
|
||||
17
web/src/routes/data/user/get-all-users.ts
Normal file
17
web/src/routes/data/user/get-all-users.ts
Normal file
@@ -0,0 +1,17 @@
|
||||
import { serverApi, UserResponseDto } from '@api';
|
||||
import type { RequestEvent, RequestHandlerOutput } from '@sveltejs/kit';
|
||||
|
||||
export const GET = async ({url} : RequestEvent): Promise<RequestHandlerOutput<UserResponseDto[]>> => {
|
||||
try {
|
||||
const isAll = url.searchParams.get('isAll') === 'true';
|
||||
|
||||
const { data } = await serverApi.userApi.getAllUsers(isAll);
|
||||
return {
|
||||
body: data
|
||||
};
|
||||
} catch {
|
||||
return {
|
||||
status: 500
|
||||
};
|
||||
}
|
||||
};
|
||||
15
web/src/routes/data/user/get-my-user-info.ts
Normal file
15
web/src/routes/data/user/get-my-user-info.ts
Normal file
@@ -0,0 +1,15 @@
|
||||
import { serverApi, UserResponseDto } from '@api';
|
||||
import type { RequestHandlerOutput } from '@sveltejs/kit';
|
||||
|
||||
export const GET = async (): Promise<RequestHandlerOutput<UserResponseDto>> => {
|
||||
try {
|
||||
const { data } = await serverApi.userApi.getMyUserInfo();
|
||||
return {
|
||||
body: data
|
||||
};
|
||||
} catch {
|
||||
return {
|
||||
status: 500
|
||||
};
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user