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

If you would like to contribute, please contact me for an API key.

Client api

These calls run through the client... and will attach required headers to the fetch request.

In the project root you will need to create a clientConfig.js file. Use the provided clientConfig_example.js as a template. This points the gui api requests to the correct place.

module.exports = {
  'host': 'https://api.srating.io/v1/',
  'api_key': '[YOUR API KEY HERE]',
  'http': 'https',
  'use_origin': false, // If true, requests will use the window.location.origin
  'path': null, // if using origin and need a path, ex: /api
};

Using the component

'use client';
import { useClientAPI } from '@/components/clientAPI';

useClientAPI({
  'class': 'cbb_game',
  'function': 'getScores',
  'arguments': {
    'start_date': '2024-01-26',
  },
}).then((response) => {
  console.log(response);
}).catch((e) => {
  console.log(e);
});

Server api

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

In the project root you will need to create a serverConfig.js file. Use the provided serverConfig_example.js as a template. This points the server api requests to the correct place.

module.exports = {
  'host': 'localhost',
  'port': 5000,
  'http': 'http',
};

Using the component

'use server';
import { useServerAPI } from '@/components/serverAPI';

const revalidateScoresSeconds = 20; // cache scores for 20 seconds
  
const scores = await useServerAPI({
  'class': 'cbb_game',
  'function': 'getScores',
  'arguments': {
    'start_date': '2024-01-26',
  }
}, {revalidate: revalidateScoresSeconds});

console.log(scores);

Pages

Other Scripts

npm run build

npm run start