This is the open-source GUI project for srating.io. This project uses nextjs, reactjs and MUI.
Prerequisites: typescript, nodejs, npm.
After cloning project, in the project directory run:
npm install
To start developing run:
npm run dev
These calls run on the client. It will attach any required headers to the fetch request.
'use client';
import { useClientAPI } from '@/components/clientAPI';
useClientAPI({
'class': 'game',
'function': 'getScores',
'arguments': {
'start_date': '2024-01-26',
},
}).then((response) => {
console.log(response);
}).catch((e) => {
console.log(e);
});
These calls run on the server. It will attach any required setting as well as handling caching the calls for performance
'use server';
import { useServerAPI } from '@/components/serverAPI';
const revalidateScoresSeconds = 20; // cache scores for 20 seconds
const scores = await useServerAPI({
'class': 'game',
'function': 'getScores',
'arguments': {
'start_date': '2024-01-26',
}
}, {revalidate: revalidateScoresSeconds});
console.log(scores);
May need to clear out .next and node_modules folder before rebuilding
rm -r node_modules
rm -r .next
You will need to set up a .env.local file. Below is an example
SERVER_PROTOCAL=http
SERVER_HOST=localhost
SERVER_PORT=3500
SERVER_SECRET=foo
NEXT_PUBLIC_CLIENT_PROTOCAL=http
NEXT_PUBLIC_CLIENT_HOST=localhost
NEXT_PUBLIC_CLIENT_PORT=4000
NEXT_PUBLIC_CLIENT_USE_ORIGIN=false
NEXT_PUBLIC_CLIENT_PATH=''
NEXT_PUBLIC_STRIPE_PUBLISHABLE_KEY=foo