Skip to content

esmalleydev/srating.io-gui

Repository files navigation

build version

This is the open-source GUI project for srating.io. This project uses nextjs, reactjs and MUI.

Prerequisites: typescript, nodejs, npm.

Looking for the API documentation?

Set up

After cloning project, in the project directory run: npm install

To start developing run: npm run dev

Client api

These calls run on the client. It will attach any required headers to the fetch request.

Using the component

'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);
});

Server api

These calls run on the server. It will attach any required setting as well as handling caching the calls for performance

Using the component

'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);

Pages

Tips

May need to clear out .next and node_modules folder before rebuilding rm -r node_modules rm -r .next

.env.local

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

Other Scripts

npm run build

npm run start