Categorygithub.com/FromhelStudio/fromhel-session-feedbacks
module
0.0.0-20241115142624-1c10d2ab7e5c
Repository: https://github.com/fromhelstudio/fromhel-session-feedbacks.git
Documentation: pkg.go.dev

# README

Fromhel Session Feedbacks

This project is a web service for collecting session feedback ratings. It is built using Go, Gin, and MongoDB.

Getting Started

Prerequisites

Installation

  1. Clone the repository:

    git clone https://github.com/FromhelStudio/fromhel-session-feedbacks.git
    cd fromhel-session-feedbacks
    
  2. Install dependencies:

    go mod tidy
    
  3. Copy the example environment file and set your MongoDB URI:

    cp .env.example .env
    

    Edit the .env file to include your MongoDB URI:

    MONGODB_URI=mongodb://your_mongodb_uri
    

Running the Server

  1. Navigate to the cmd/server directory:

    cd cmd/server
    
  2. Run the server:

    go run [main.go](http://_vscodecontentref_/17)
    

    The server will start on http://localhost:8080.

API Endpoints

Create Rating

  • URL: /rating

  • Method: POST

  • Request Body:

    {
      "rating": 1,
      "feedback": "Your feedback here",
      "gameName": "bulletspeel" // bulletspeel or cordel only
    }
    
  • Response:

    {
      "message": "Rating created",
      "statusCode": 201
    }
    

Get Ratings

  • URL: /rating/:page

  • Method: GET

  • Query Parameters:

    • game (required): The name of the game (either "bulletspeel" or "cordel")
  • Response:

    {
      "ratings": [
        {
          "id": "string",
          "game": "string",
          "rating": 1,
          "feedback": "string",
          "createdAt": "string"
        }
      ],
      "statusCode": 200
    }
    

Create Session

  • URL: /session

  • Method: POST

  • Request Body:

    {
      "gameName": "bulletspeel", // bulletspeel or cordel only
      "timespent": 0,
      "deaths": 0,
      "colorPicked": 0,
      "enemysKilled": 0,
      "gameFinished": true,
      "money": 0,
      "ammunation": 0,
      "items": true
    }
    
  • Response:

    {
      "message": "Created.",
      "statusCode": 201
    }
    

Get Sessions

  • URL /session/:page

  • Method GET

  • Query Parameters:

    • game (required): The name of the game (either "bulletspeel" or "cordel")
  • Response

    {
      "sessions": [
        {
          "Id": "UUID/string",
          "Game": "string",
          "Timespent": 1,
          "Deaths": 1,
          "ColorPicked": 1,
          "EnemysKilled": 1,
          "GameFinished": true,
          "Money": 1,
          "Ammunation": 1,
          "Items": true,
          "CreatedAt": "Date/string"
        }
      ],
      "statusCode": 200
    }
    

Project Details

  • Rating Model: Defined in rating.go
  • Rating Service: Handles the creation of ratings in MongoDB, defined in rating.go
  • Create Rating Handler: Handles the HTTP request for creating a rating, defined in rating.go
  • Get Ratings Handler: Handles the HTTP request for retrieving ratings, defined in rating.go
  • Session Model: Defined in sessions.go
  • Session Service: Handles the creation of sessions in MongoDB, defined in sessions.go
  • Create Session Handler: Handles the HTTP request for creating a session, defined in sessions.go
  • Router Initialization: Sets up the routes and loads environment variables, defined in router.go

# Packages

No description provided by the author