Giter VIP home page Giter VIP logo

zombie-survival-social-network's Introduction

Requirement

node v16.14.2
mysql v8.0.29

Installation

  1. Install dependencies
npm install
  1. Create database (e.g. zsn)
create database zsn
  1. Set MYSQL configuration at /config/Env.json
  2. Run schema.sql file to generate database schema
  3. Run the application (by default it will run at port 5050)
npm run start

API Docs

Register Survivor

POST /survivor/register
content-type: "application/json"
request:
{
    "name": "Joe",
    "age": "20",
    "gender": "MALE",
    "waterTotal": 10,
    "foodTotal": 20,
    "medicationTotal": 10,
    "ammunitionTotal": 2
}
response:
{
    "status": "success",
    "data": {
        "id": 1,
        "name": "Joe",
        "age": "20",
        "gender": "MALE",
        "waterTotal": 10,
        "foodTotal": 20,
        "medicationTotal": 10,
        "ammunitionTotal": 2
    }
}

Update Survival Location

PATCH /survivor/:survivorId/update-location
params: survivorId
content-type: "application/json"
request:
{
    "latitude": "-21992.39723",
    "longitude": "882982.2313"
}
response:
{
    "status": "success",
    "data": "Location updated"
}

Report Contamination Survivor

Field Description
fromSurvivorId survivor id as who's reporting
toSurvivorId survivor id as who's contaminated
POST /contamination/report-survivor
content-type: "application/json"
request:
{
    "fromSurvivorId": 1,
    "toSurvivorId": 2
}
response:
{
    "status": "success",
    "data": "success"
}
error:
{
    "status": "error",
    "message": "You already reported this survivor"
}

Trade

Field Description
buyerSurvivorId survivor id as a buyer
sellerSurvivorId survivor id as a seller
POST /trade
content-type: "application/json"
request:
{
    "buyerSurvivorId": 1,
    "sellerSurvivorId": 2,

    "waterTotalBuyer": "0",
    "foodTotalBuyer": "0",
    "medicationTotalBuyer": "0",
    "ammunitionTotalBuyer": "6",
    
    "waterTotalSeller": "1",
    "foodTotalSeller": "0",
    "medicationTotalSeller": "1",
    "ammunitionTotalSeller": "0"
}
response:
{
    "status": "success",
    "data": "Trade success"
}
error:
{
    "status": "error",
    "message": "Trade failed. Item points not satisfied"
}

Report Survivor Percentage

GET /report/survivor-percentage
content-type: "application/json"
response:
{
    "status": "success",
    "data": {
        "infectedSurvivorPercentage": "0.00",
        "notInfectedSurvivorPercentage": "100.00"
    }
}

Report Average Amount Item

GET /report/average-amount-item
content-type: "application/json"
response:
{
    "status": "success",
    "data": {
        "waterAverage": "10.0000",
        "foodAverage": "20.0000",
        "medicationAverage": "10.0000",
        "ammunitionAverage": "2.0000"
    }
}

Report Point Lost

GET /report/point-lost
content-type: "application/json"
response:
{
    "status": "success",
    "data": 27
}

zombie-survival-social-network's People

Contributors

ariframadhani avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.