Skip to content

Pixel Punch Out Server is the backend server for the our game, built with Node.js and Express. This server handles multiplayer game logic, real-time communication between players, and game state synchronization. It demonstrates efficient use of WebSockets for real-time interactions and provides a robust backend for the Pixel Punch Out game.

Notifications You must be signed in to change notification settings

OwenOrcan/Pixel-Punch-Out-Server

 
 

Repository files navigation

Pixel Punch-Out Server

Welcome to the Pixel Punch-Out Server repository! This server manages player profiles, authentication, and other essential backend services for the Pixel Punch-Out game.

Table of Contents

Introduction

The Pixel Punch-Out Server is dedicated to handling player profiles, authentication, and other backend functionalities that support the main game logic handled by a separate WebSocket server. Built with Node.js and MySQL, it ensures secure and efficient management of player data.

Features

  • Player Profiles: Create and manage player profiles.
  • Authentication: Secure user login and registration.
  • Profile Interactions: Comment on player profiles, update profile photos, and more.

Technologies Used

  • Backend: Node.js, Express.js
  • Database: MySQL
  • ORM: Knex.js

Getting Started

Prerequisites

Make sure you have the following installed:

  • Node.js
  • npm
  • MySQL

Installation

  1. Clone the repository:

    git clone https://github.com/yigitocak/Pixel-Punch-Out-Server.git
    cd Pixel-Punch-Out-Server
  2. Install dependencies:

    npm install
  3. Set up environment variables: Create a .env file in the root directory and add your MySQL connection details and other necessary environment variables.

    DB_HOST=your_mysql_host
    DB_USER=your_mysql_user
    DB_PASSWORD=your_mysql_password
    DB_DATABASE=your_mysql_database
    BACKEND_URL=your_backend_url
    CLOUDINARY_API_KEY=your_cloudinary_api_key
    CLOUDINARY_API_SECRET=your_cloudinary_api_secret
    CLOUDINARY_CLOUD_NAME=your_cloudinary_cloud_name
    DISCORD_CLIENT_ID=your_discord_client_id
    DISCORD_CLIENT_SECRET=your_discord_client_secret
    DISCORD_TOKEN=your_discord_token
    EMAIL=your_website_email
    EMAIL_PASSWORD=your_website_email_password
    GOOGLE_CLIENT_ID=your_google_client_id
    GOOGLE_CLIENT_SECRET=your_google_client_secret
    NODE_ENV=development_production
    SECRET_KEY=your_secret_key
    PORT=your_port_number
  4. Run the server:

    npm start

Usage

Once the server is running, it will handle player profiles, authentication, and other backend tasks. Connect your front-end or WebSocket server to this backend to utilize these services.

API Endpoints

Authentication

  • Authenticate Token:

    GET /auth/ (header) 
    {
      "token": "your_token"
    }
  • Register:

    POST /auth/signup
    {
      "email": "your_email",
      "username": "your_username",
      "password": "your_password"
    }
  • Login:

    POST /auth/login
    {
      "username": "your_username",
      "password": "your_password"
    }
  • Verify:

    POST /auth/verify
    {
      "email": "your_email",
      "code": "your_code"
    }
  • Reset:

    POST /auth/reset
    {
      "email": "your_email"
    }
  • Validate Reset:

    POST /auth/validateReset
    {
      "email": "your_email",
      "code": "your_code"
    }
  • Reset Password:

    POST /auth/resetPassword
    {
      "email": "your_email",
      "newPassword": "your_new_password",
      "secret": "your_secret"
    }

Profiles

  • All Profiles:

    GET /profiles/
  • Fetch Specific User With ID:

    GET /profiles/id/:id
  • Fetch Specific User:

    GET /profiles/:username
  • Change Username:

    POST /profiles/username
    {
      "newUsername": "your_new_username"
    }
  • Upload Photo:

    POST /profiles/:username/uploadPhoto
    {
      "file": "your_profile_photo"
    }
  • Delete Profile:

    DELETE /profiles/:username
  • Increment Wins:

    POST /profiles/:username/wins
    {
      "secret": "your_secret"
    }
  • Increment Losses:

    POST /profiles/:username/losses
    {
      "secret": "your_secret"
    }
  • Post Comment:

    POST /profiles/:username/comments
    {
      "commentUsername": "your_username",
      "comment": "your_comment"
    }
  • Delete Comment:

    DELETE /profiles/:username/comments/:commentId

Leaderboard

  • Leaderboard:
    GET /leaderboard

Discord

  • User Discord Data:

    POST /discord/getuserData
    {
      "discordId": "your_discord_id"
    }
  • User Discord Verify:

    GET /discord/verify
  • User Discord Verify Callback:

    GET /discord/verify/callback
  • User Discord OAuth Login:

    GET /discord/oauth/login

OAuth

  • Google Callback:
    POST /oauth/google/callback
    {
      "token": "your_token"
    }

Contributing

We welcome contributions! Here’s how you can help:

  1. Fork the repository.
  2. Create a new branch: git checkout -b feature/your-feature
  3. Commit your changes: git commit -m 'Add some feature'
  4. Push to the branch: git push origin feature/your-feature
  5. Create a Pull Request.

Contact

Have questions or feedback? Let’s connect!

About

Pixel Punch Out Server is the backend server for the our game, built with Node.js and Express. This server handles multiplayer game logic, real-time communication between players, and game state synchronization. It demonstrates efficient use of WebSockets for real-time interactions and provides a robust backend for the Pixel Punch Out game.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 94.8%
  • HTML 5.2%