AkashSDas / knightfall

Responsive web app to play chess with other players matched based on rankings, real-time notifications, and chat with friends.
MIT License
0 stars 0 forks source link

Set up Frontend and Backend Infrastructure #1

Closed AkashSDas closed 3 months ago

AkashSDas commented 3 months ago

In the backend:

In the frontend:

AkashSDas commented 3 months ago

Set up for frontend and backend has been done in this PR. While setting up the front end, I faced the following issues:

ChakraCLI and fontsource

When generating theme types using the ChakraCLI else it gives the following error:

Chakra UI CLI  v2.4.1 by Chakra UI
Generate theme typings for autocomplete
✘ [ERROR] No loader is configured for ".woff2" files: node_modules/.pnpm/@fontsource-variable+nunito@5.0.19/node_modules/@fontsource-variable/nunito/files/nunito-latin-wght-normal.woff2
     node_modules/.pnpm/@fontsource-variable+nunito@5.0.19/node_modules/@fontsource-variable/nunito/index.css:47:7:
       47 │   src: url(./files/nunito-latin-wght-normal.woff2) format('woff2-variations');

I've tried using unplugin-fonts/vite but it didn't work. Also, to make ChakraCLI work with ppm I had to install @chakra-ui/styled-system as a dev dependency. https://github.com/chakra-ui/chakra-ui/issues/5919

All of this is done to use ChakraCLI for custom types in colors, ... but it isn't as beneficial as to go and look for the above issues.

Typescript

In some places, Typescript was giving errors. This happened for Redux Toolkit and React Router.

The following issues provide more context on the issue faced:

In place of Redux, the issue was solved by this:

// Here this issue is faced by `useAppDispatch`
// eslint-disable-next-line @typescript-eslint/no-unused-vars
import type * as _Redux from "@reduxjs/toolkit";

export const useAppSelector: TypedUseSelectorHook<RootState> = useSelector;
export const useAppDispatch = () => useDispatch<AppDispatch>();

The best way to solve this issue is to provide an explicit type hint to the variable for which you're facing this issue. For React Router I created frontend/lib/routes.ts and exported the route variable. For this, I was getting this error, but when I directly used it in App.tsx then I wasn't getting this error. If a variable is exported then this error arises for a few identifiers.