Skip to content

Commit

Permalink
Add ts-reset
Browse files Browse the repository at this point in the history
  • Loading branch information
karniv00l committed Mar 2, 2023
1 parent 7f35d35 commit 55248f7
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 5 deletions.
7 changes: 7 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
"vite": "^4.1.4"
},
"devDependencies": {
"@total-typescript/ts-reset": "^0.3.7",
"@types/lodash.debounce": "^4.0.7",
"@types/node": "^18.14.4",
"@types/pako": "^2.0.0",
Expand Down
15 changes: 10 additions & 5 deletions src/hooks/useDb.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,11 @@ type TunesResponseList = {
totalItems: number;
};

type ToggleStarResponse = {
stars: number;
isStarred: boolean;
};

const tunesCollection = client.collection(Collections.Tunes);

const customEndpoint = `${API_URL}/api/custom`;
Expand Down Expand Up @@ -63,7 +68,7 @@ const useDb = () => {
const response = await fetch(`${customEndpoint}/tunes/byTuneId/${tuneId}`);

if (response.ok) {
return response.json();
return response.json() as Promise<TunesResponse>;
}

if (response.status === 404) {
Expand All @@ -80,7 +85,7 @@ const useDb = () => {
const response = await fetch(`${customEndpoint}/iniFiles/bySignature/${signature}`);

if (response.ok) {
return response.json();
return response.json() as Promise<IniFilesResponse>;
}

if (response.status === 404) {
Expand Down Expand Up @@ -185,15 +190,15 @@ const useDb = () => {
const toggleStar = async (
currentUserToken: string,
tune: string,
): Promise<{ stars: number; isStarred: boolean }> => {
): Promise<ToggleStarResponse> => {
const response = await fetch(`${customEndpoint}/stargazers/toggleStar`, {
method: 'POST',
headers: headers(currentUserToken),
body: JSON.stringify({ tune }),
});

if (response.ok) {
const { stars, isStarred } = await response.json();
const { stars, isStarred } = (await response.json()) as ToggleStarResponse;

return Promise.resolve({ stars, isStarred });
}
Expand All @@ -219,7 +224,7 @@ const useDb = () => {
});

if (response.ok) {
const { isStarred } = await response.json();
const { isStarred } = (await response.json()) as ToggleStarResponse;

return Promise.resolve(isStarred);
}
Expand Down
2 changes: 2 additions & 0 deletions src/main.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ import { environment, isProduction, sentryDsn } from './utils/env';
import { AuthProvider } from './contexts/AuthContext';
import CommandPalette from './components/CommandPalette';

import '@total-typescript/ts-reset';

if (isProduction) {
Sentry.init({
dsn: sentryDsn as string,
Expand Down

0 comments on commit 55248f7

Please sign in to comment.