Skip to content

Rename backend function calling iggy to be clearer #24

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
services:
iggy-server:
image: iggyrs/iggy:0.4.72
image: iggyrs/iggy:0.4.214
environment:
IGGY_ROOT_USERNAME: admin
IGGY_ROOT_PASSWORD: admin
Expand Down
4 changes: 2 additions & 2 deletions src/hooks.client.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { Handle, HandleClientError } from '@sveltejs/kit';
import type { HandleClientError } from '@sveltejs/kit';

export const handleError: HandleClientError = async ({ error, event }) => {
export const handleError: HandleClientError = async ({ error }) => {
console.log('client error handler', error);
return {
message: 'Whoops!',
Expand Down
3 changes: 1 addition & 2 deletions src/hooks.server.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
import { env } from '$env/dynamic/public';
import { fetchApi } from '$lib/api/fetchApi';
import { checkIfPathnameIsPublic, typedRoute } from '$lib/types/appRoutes';
import { tokens } from '$lib/utils/constants/tokens';
import type { Handle } from '@sveltejs/kit';
import { sequence } from '@sveltejs/kit/hooks';
import { redirect, type Actions } from '@sveltejs/kit';
import { redirect } from '@sveltejs/kit';

console.log(`IggyAPI URL: ${env.PUBLIC_IGGY_API_URL}`)

Expand Down
2 changes: 1 addition & 1 deletion src/lib/api/fetchApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import type { ApiSchema } from '$lib/api/ApiSchema';
import { tokens } from '$lib/utils/constants/tokens';
import { type Cookies } from '@sveltejs/kit';

export async function fetchApi(
export async function fetchIggyBackendApi(
args: ApiSchema & { queryParams?: Record<string, string>; cookies?: Cookies }
): Promise<Response | unknown> {
const { path, method, queryParams, cookies } = args;
Expand Down
4 changes: 2 additions & 2 deletions src/routes/api/proxy/+server.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { fetchApi } from '$lib/api/fetchApi';
import { fetchIggyBackendApi } from '$lib/api/fetchApi';
import { handleFetchErrors } from '$lib/api/handleFetchErrors';
import { error, json, type RequestHandler } from '@sveltejs/kit';
import { convertBigIntsToStrings } from '$lib/api/convertBigIntsToStrings';
Expand All @@ -14,7 +14,7 @@ export const POST: RequestHandler = async ({ request, cookies }) => {
});
}

const result = await fetchApi({ body, path, method, cookies, queryParams });
const result = await fetchIggyBackendApi({ body, path, method, cookies, queryParams });

const { data, response } = await handleFetchErrors(result, cookies);

Expand Down
6 changes: 3 additions & 3 deletions src/routes/auth/sign-in/+page.server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { message, superValidate } from 'sveltekit-superforms/server';
import { zod } from 'sveltekit-superforms/adapters';
import { z } from 'zod';
import { typedRoute } from '$lib/types/appRoutes';
import { fetchApi } from '$lib/api/fetchApi';
import { fetchIggyBackendApi } from '$lib/api/fetchApi';
import { tokens } from '$lib/utils/constants/tokens';
import { getJson } from '$lib/api/getJson';

Expand All @@ -20,7 +20,7 @@ export const load = async () => {
};

export const actions = {
default: async ({ request, cookies, locals }) => {
default: async ({ request, cookies }) => {
const form = await superValidate(request, zod(schema));

if (!form.valid) {
Expand All @@ -29,7 +29,7 @@ export const actions = {

const { password, username } = form.data;

const result = await fetchApi({
const result = await fetchIggyBackendApi({
method: 'POST',
path: '/users/login',
body: { username, password }
Expand Down
6 changes: 3 additions & 3 deletions src/routes/dashboard/+layout.server.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { fetchApi } from '$lib/api/fetchApi';
import { fetchIggyBackendApi } from '$lib/api/fetchApi';
import { handleFetchErrors } from '$lib/api/handleFetchErrors';
import { userDetailsMapper } from '$lib/domain/UserDetails';
import type { LayoutServerLoad } from './$types';
Expand All @@ -10,8 +10,8 @@ export const load: LayoutServerLoad = async ({ cookies }) => {
const accessToken = cookies.get('access_token')!;
const userId = jwtDecode(accessToken).sub!;

const userResult = await fetchApi({ method: 'GET', path: `/users/${+userId}`, cookies });
const { data, response } = await handleFetchErrors(userResult, cookies);
const userResult = await fetchIggyBackendApi({ method: 'GET', path: `/users/${+userId}`, cookies });
const { data } = await handleFetchErrors(userResult, cookies);

return userDetailsMapper(data);
};
Expand Down
4 changes: 2 additions & 2 deletions src/routes/dashboard/overview/+page.server.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { fetchApi } from '$lib/api/fetchApi';
import { fetchIggyBackendApi } from '$lib/api/fetchApi';
import { handleFetchErrors } from '$lib/api/handleFetchErrors';
import { statsMapper } from '$lib/domain/Stats';

export const load = async ({ cookies }) => {
const result = await fetchApi({
const result = await fetchIggyBackendApi({
path: '/stats',
method: 'GET',
cookies
Expand Down
4 changes: 2 additions & 2 deletions src/routes/dashboard/settings/server/+page.server.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { fetchApi } from '$lib/api/fetchApi';
import { fetchIggyBackendApi } from '$lib/api/fetchApi';
import { handleFetchErrors } from '$lib/api/handleFetchErrors';
import { statsMapper } from '$lib/domain/Stats';

export const load = async ({ cookies }) => {
const getStats = async () => {
const result = await fetchApi({
const result = await fetchIggyBackendApi({
method: 'GET',
path: '/stats',
cookies
Expand Down
8 changes: 4 additions & 4 deletions src/routes/dashboard/settings/users/+page.server.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { fetchApi } from '$lib/api/fetchApi';
import { fetchIggyBackendApi } from '$lib/api/fetchApi';
import { handleFetchErrors } from '$lib/api/handleFetchErrors';
import { streamListMapper } from '$lib/domain/Stream';
import { streamDetailsMapper } from '$lib/domain/StreamDetails.js';
Expand All @@ -7,7 +7,7 @@ import { userMapper, type User } from '$lib/domain/User.js';

export const load = async ({ cookies }) => {
const getUsers = async () => {
const result = await fetchApi({
const result = await fetchIggyBackendApi({
method: 'GET',
path: '/users',
cookies
Expand All @@ -18,7 +18,7 @@ export const load = async ({ cookies }) => {
};

const getStreams = async () => {
const result = await fetchApi({
const result = await fetchIggyBackendApi({
method: 'GET',
path: '/streams',
cookies
Expand All @@ -34,7 +34,7 @@ export const load = async ({ cookies }) => {
};
}

const streamDetailResult = await fetchApi({
const streamDetailResult = await fetchIggyBackendApi({
method: 'GET',
path: `/streams/${streams[0].id}`,
cookies
Expand Down
4 changes: 2 additions & 2 deletions src/routes/dashboard/streams/+layout.server.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { fetchApi } from '$lib/api/fetchApi';
import { fetchIggyBackendApi } from '$lib/api/fetchApi';
import { handleFetchErrors } from '$lib/api/handleFetchErrors';
import { streamMapper, type Stream } from '$lib/domain/Stream';
import type { LayoutServerLoad } from './$types';

export const load: LayoutServerLoad = async ({ cookies }) => {
const result = await fetchApi({
const result = await fetchIggyBackendApi({
method: 'GET',
path: '/streams',
cookies
Expand Down
4 changes: 2 additions & 2 deletions src/routes/dashboard/streams/[streamId=i32]/+page.server.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { fetchApi } from '$lib/api/fetchApi.js';
import { fetchIggyBackendApi } from '$lib/api/fetchApi.js';
import { handleFetchErrors } from '$lib/api/handleFetchErrors';
import { streamDetailsMapper } from '$lib/domain/StreamDetails';

export const load = async ({ params, cookies }) => {
const getStreamDetails = async () => {
const result = await fetchApi({
const result = await fetchIggyBackendApi({
method: 'GET',
path: `/streams/${+params.streamId}`,
cookies
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { fetchApi } from '$lib/api/fetchApi';
import { fetchIggyBackendApi } from '$lib/api/fetchApi';
import { handleFetchErrors } from '$lib/api/handleFetchErrors';
import { topicDetailsMapper } from '$lib/domain/TopicDetails';

export const load = async ({ params, cookies }) => {
const getTopic = async () => {
const result = await fetchApi({
const result = await fetchIggyBackendApi({
method: 'GET',
path: `/streams/${+params.streamId}/topics/${+params.topicId}`,
cookies
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { fetchApi } from '$lib/api/fetchApi';
import { fetchIggyBackendApi } from '$lib/api/fetchApi';
import { handleFetchErrors } from '$lib/api/handleFetchErrors';
import { partitionMessagesDetailsMapper } from '$lib/domain/MessageDetails';
import { topicDetailsMapper } from '$lib/domain/TopicDetails';
Expand All @@ -10,7 +10,7 @@ export const load = async ({ params, cookies, url }) => {
const direction = url.searchParams.get('direction') || 'desc';

const getPartitionMessages = async () => {
const initialResult = await fetchApi({
const initialResult = await fetchIggyBackendApi({
method: 'GET',
path: `/streams/${+params.streamId}/topics/${+params.topicId}/messages`,
cookies,
Expand All @@ -31,7 +31,7 @@ export const load = async ({ params, cookies, url }) => {
url.searchParams.get('offset') ??
(direction === 'desc' ? Math.max(0, totalMessages - MESSAGES_PER_PAGE) : '0');

const result = await fetchApi({
const result = await fetchIggyBackendApi({
method: 'GET',
path: `/streams/${+params.streamId}/topics/${+params.topicId}/messages`,
cookies,
Expand All @@ -49,7 +49,7 @@ export const load = async ({ params, cookies, url }) => {
};

const getTopic = async () => {
const result = await fetchApi({
const result = await fetchIggyBackendApi({
method: 'GET',
path: `/streams/${+params.streamId}/topics/${+params.topicId}`,
cookies
Expand Down