Start of backend and webserver

This commit is contained in:
Gnarwhal 2021-01-27 14:35:09 -05:00
parent a06a558d7b
commit e7e5168073
Signed by: Gnarwhal
GPG key ID: 0989A73D8C421174
22 changed files with 130 additions and 283 deletions

182
.gitignore vendored
View file

@ -1,182 +0,0 @@
# Created by https://www.toptal.com/developers/gitignore/api/vscode,intellij,eclipse
# Edit at https://www.toptal.com/developers/gitignore?templates=vscode,intellij,eclipse
### Eclipse ###
.metadata
bin/
tmp/
*.tmp
*.bak
*.swp
*~.nib
local.properties
.settings/
.loadpath
.recommenders
# External tool builders
.externalToolBuilders/
# Locally stored "Eclipse launch configurations"
*.launch
# PyDev specific (Python IDE for Eclipse)
*.pydevproject
# CDT-specific (C/C++ Development Tooling)
.cproject
# CDT- autotools
.autotools
# Java annotation processor (APT)
.factorypath
# PDT-specific (PHP Development Tools)
.buildpath
# sbteclipse plugin
.target
# Tern plugin
.tern-project
# TeXlipse plugin
.texlipse
# STS (Spring Tool Suite)
.springBeans
# Code Recommenders
.recommenders/
# Annotation Processing
.apt_generated/
.apt_generated_test/
# Scala IDE specific (Scala & Java development for Eclipse)
.cache-main
.scala_dependencies
.worksheet
# Uncomment this line if you wish to ignore the project description file.
# Typically, this file would be tracked if it contains build/dependency configurations:
#.project
### Eclipse Patch ###
# Spring Boot Tooling
.sts4-cache/
### Intellij ###
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio, WebStorm and Rider
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839
# User-specific stuff
.idea/**/workspace.xml
.idea/**/tasks.xml
.idea/**/usage.statistics.xml
.idea/**/dictionaries
.idea/**/shelf
# Generated files
.idea/**/contentModel.xml
# Sensitive or high-churn files
.idea/**/dataSources/
.idea/**/dataSources.ids
.idea/**/dataSources.local.xml
.idea/**/sqlDataSources.xml
.idea/**/dynamic.xml
.idea/**/uiDesigner.xml
.idea/**/dbnavigator.xml
# Gradle
.idea/**/gradle.xml
.idea/**/libraries
# Gradle and Maven with auto-import
# When using Gradle or Maven with auto-import, you should exclude module files,
# since they will be recreated, and may cause churn. Uncomment if using
# auto-import.
# .idea/artifacts
# .idea/compiler.xml
# .idea/jarRepositories.xml
# .idea/modules.xml
# .idea/*.iml
# .idea/modules
# *.iml
# *.ipr
# CMake
cmake-build-*/
# Mongo Explorer plugin
.idea/**/mongoSettings.xml
# File-based project format
*.iws
# IntelliJ
out/
# mpeltonen/sbt-idea plugin
.idea_modules/
# JIRA plugin
atlassian-ide-plugin.xml
# Cursive Clojure plugin
.idea/replstate.xml
# Crashlytics plugin (for Android Studio and IntelliJ)
com_crashlytics_export_strings.xml
crashlytics.properties
crashlytics-build.properties
fabric.properties
# Editor-based Rest Client
.idea/httpRequests
# Android studio 3.1+ serialized cache file
.idea/caches/build_file_checksums.ser
### Intellij Patch ###
# Comment Reason: https://github.com/joeblau/gitignore.io/issues/186#issuecomment-215987721
# *.iml
# modules.xml
# .idea/misc.xml
# *.ipr
# Sonarlint plugin
# https://plugins.jetbrains.com/plugin/7973-sonarlint
.idea/**/sonarlint/
# SonarQube Plugin
# https://plugins.jetbrains.com/plugin/7238-sonarqube-community-plugin
.idea/**/sonarIssues.xml
# Markdown Navigator plugin
# https://plugins.jetbrains.com/plugin/7896-markdown-navigator-enhanced
.idea/**/markdown-navigator.xml
.idea/**/markdown-navigator-enh.xml
.idea/**/markdown-navigator/
# Cache file creation bug
# See https://youtrack.jetbrains.com/issue/JBR-2257
.idea/$CACHE_FILE$
# CodeStream plugin
# https://plugins.jetbrains.com/plugin/12206-codestream
.idea/codestream.xml
### vscode ###
.vscode/*
!.vscode/settings.json
!.vscode/tasks.json
!.vscode/launch.json
!.vscode/extensions.json
*.code-workspace
# End of https://www.toptal.com/developers/gitignore/api/vscode,intellij,eclipse

2
backend/.gitignore vendored
View file

@ -18,4 +18,4 @@ gradlew.bat
.settings/
# Local property file
src/main/resources/application-db.properties
src/main/resources/application-*.properties

View file

@ -20,5 +20,5 @@ dependencies {
}
tasks.getByName('bootRun') {
systemProperty 'spring.profiles.active', 'db'
systemProperty 'spring.profiles.active', 'local'
}

View file

@ -20,7 +20,7 @@ public class Controller {
public Controller() {}
@RequestMapping(value = "/achievements", method = GET, produces = "application/json")
public ResponseEntity index() {
public ResponseEntity<String> index() {
try {
var achievements = db.getAchievements();
var mapper = new ObjectMapper();

View file

@ -6,7 +6,6 @@ import org.springframework.stereotype.Component;
import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import com.microsoft.sqlserver.jdbc.SQLServerDataSource;

View file

@ -1,2 +1,2 @@
server.port = 8000
server.port = 4730
spring.application.name = Achievements Project

3
frontend/.gitignore vendored Normal file
View file

@ -0,0 +1,3 @@
# Node files
node_modules/
package-lock.json

30
frontend/config.js Normal file
View file

@ -0,0 +1,30 @@
const fs = require("fs");
const loadConfig = module.exports.load = (configPath) => {
function writeToObject(write, read) {
for (const key in read) {
if (typeof read[key] === 'object') {
if (write[key] != null) {
writeToObject(write[key], read[key]);
} else {
write[key] = read[key];
}
} else {
write[key] = read[key];
}
}
}
const baseConfig = JSON.parse(fs.readFileSync(configPath));
const config = {};
if (baseConfig.extends !== undefined) {
for (const path of baseConfig.extends) {
const parent = loadConfig(path);
writeToObject(config, parent);
}
}
writeToObject(config, baseConfig);
delete config.extends;
return config;
};

View file

@ -0,0 +1 @@
{}

View file

@ -0,0 +1,7 @@
{
"extends": [
"config/base.json"
],
"build": "debug",
"port": 8080
}

View file

@ -0,0 +1,7 @@
{
"extends": [
"config/base.json"
],
"build": "release",
"port": 80
}

19
frontend/package.json Normal file
View file

@ -0,0 +1,19 @@
{
"name": "frontend",
"version": "1.0.0",
"description": "Cross platform achievement tracker",
"repository": "github:Gnarwhal/AchievementProject",
"main": "static_server.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"debug": "node static_server.js config/debug.json",
"release": "node static_server.js config/release.json"
},
"author": "",
"license": "ISC",
"dependencies": {
"express": "^4.17.1",
"morgan": "^1.10.0",
"xml2js": "^0.4.23"
}
}

58
frontend/static_server.js Normal file
View file

@ -0,0 +1,58 @@
const express = require('express');
const morgan = require('morgan' );
const fs = require('fs' );
const http = require('http' );
const config = require('./config.js').load(process.argv[2]);
const app = express();
app.use("/", morgan("dev"));
app.use("/", (request, response, next) => {
/*if (request.headers['accept'].split(',')[0] === 'text/html') {
let path = request.url;
if (path === '/') {
path = "/index.html";
}
path = 'webpage' + path;
fs.readFile(path, 'utf8', (err, fileData) => {
if (err) {
response.statusCode = 500;
response.statusMessage = 'Unkown file read error';
console.log(err);
}
if (path === 'webpage/index.html') {
console.log("ummmm");
dbRequest = http.get("http://localhost:4730/achievements", dbResponse => {
console.log("Yesting?");
dbResponse.on('data', achievementData => {
console.log("Hello?");
achievementData = JSON.parse(achievementData);
let list = "";
for (const achievement of achievementData.achievements) {
list = list +
`<div class="list-page-list-entry">
<img class="achievement-list-page-entry-icon" src="res/dummy_achievement.png" alt="Achievement Icon.png" />
<p class="achievement-list-page-entry-name">${achievement.name}</p>
<p class="achievement-list-page-entry-description">${achievement.description}</p>
<p class="achievement-list-page-entry-game">${achievement.gameID}</p>
</div>`;
}
response.statusCode = 200;
response.statusMessage = 'OK';
response.write(Buffer.from(fileDate.replace("\${list}", list), 'utf8'));
response.end();
});
});
}
});
} else {
next();
}*/
next();
});
app.use("/", express.static("webpage"));
app.listen(config.port);

View file

@ -116,102 +116,7 @@
<p class="achievement-list-page-entry-description">Description</p>
<p class="achievement-list-page-entry-game">Game</p>
</div>
<div class="list-page-list-entry">
<img class="achievement-list-page-entry-icon" src="res/dummy_achievement.png" alt="Achievement Icon.png" />
<p class="achievement-list-page-entry-name">Lorem Ipsum</p>
<p class="achievement-list-page-entry-description">Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</p>
<p class="achievement-list-page-entry-game">Latin</p>
</div>
<div class="list-page-list-entry">
<img class="achievement-list-page-entry-icon" src="res/dummy_achievement.png" alt="Achievement Icon.png" />
<p class="achievement-list-page-entry-name">Lorem Ipsum</p>
<p class="achievement-list-page-entry-description">Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</p>
<p class="achievement-list-page-entry-game">Latin</p>
</div>
<div class="list-page-list-entry">
<img class="achievement-list-page-entry-icon" src="res/dummy_achievement.png" alt="Achievement Icon.png" />
<p class="achievement-list-page-entry-name">Lorem Ipsum</p>
<p class="achievement-list-page-entry-description">Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</p>
<p class="achievement-list-page-entry-game">Latin</p>
</div>
<div class="list-page-list-entry">
<img class="achievement-list-page-entry-icon" src="res/dummy_achievement.png" alt="Achievement Icon.png" />
<p class="achievement-list-page-entry-name">Lorem Ipsum</p>
<p class="achievement-list-page-entry-description">Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</p>
<p class="achievement-list-page-entry-game">Latin</p>
</div>
<div class="list-page-list-entry">
<img class="achievement-list-page-entry-icon" src="res/dummy_achievement.png" alt="Achievement Icon.png" />
<p class="achievement-list-page-entry-name">Lorem Ipsum</p>
<p class="achievement-list-page-entry-description">Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</p>
<p class="achievement-list-page-entry-game">Latin</p>
</div>
<div class="list-page-list-entry">
<img class="achievement-list-page-entry-icon" src="res/dummy_achievement.png" alt="Achievement Icon.png" />
<p class="achievement-list-page-entry-name">Lorem Ipsum</p>
<p class="achievement-list-page-entry-description">Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</p>
<p class="achievement-list-page-entry-game">Latin</p>
</div>
<div class="list-page-list-entry">
<img class="achievement-list-page-entry-icon" src="res/dummy_achievement.png" alt="Achievement Icon.png" />
<p class="achievement-list-page-entry-name">Lorem Ipsum</p>
<p class="achievement-list-page-entry-description">Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</p>
<p class="achievement-list-page-entry-game">Latin</p>
</div>
<div class="list-page-list-entry">
<img class="achievement-list-page-entry-icon" src="res/dummy_achievement.png" alt="Achievement Icon.png" />
<p class="achievement-list-page-entry-name">Lorem Ipsum</p>
<p class="achievement-list-page-entry-description">Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</p>
<p class="achievement-list-page-entry-game">Latin</p>
</div>
<div class="list-page-list-entry">
<img class="achievement-list-page-entry-icon" src="res/dummy_achievement.png" alt="Achievement Icon.png" />
<p class="achievement-list-page-entry-name">Lorem Ipsum</p>
<p class="achievement-list-page-entry-description">Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</p>
<p class="achievement-list-page-entry-game">Latin</p>
</div>
<div class="list-page-list-entry">
<img class="achievement-list-page-entry-icon" src="res/dummy_achievement.png" alt="Achievement Icon.png" />
<p class="achievement-list-page-entry-name">Lorem Ipsum</p>
<p class="achievement-list-page-entry-description">Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</p>
<p class="achievement-list-page-entry-game">Latin</p>
</div>
<div class="list-page-list-entry">
<img class="achievement-list-page-entry-icon" src="res/dummy_achievement.png" alt="Achievement Icon.png" />
<p class="achievement-list-page-entry-name">Lorem Ipsum</p>
<p class="achievement-list-page-entry-description">Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</p>
<p class="achievement-list-page-entry-game">Latin</p>
</div>
<div class="list-page-list-entry">
<img class="achievement-list-page-entry-icon" src="res/dummy_achievement.png" alt="Achievement Icon.png" />
<p class="achievement-list-page-entry-name">Lorem Ipsum</p>
<p class="achievement-list-page-entry-description">Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</p>
<p class="achievement-list-page-entry-game">Latin</p>
</div>
<div class="list-page-list-entry">
<img class="achievement-list-page-entry-icon" src="res/dummy_achievement.png" alt="Achievement Icon.png" />
<p class="achievement-list-page-entry-name">Lorem Ipsum</p>
<p class="achievement-list-page-entry-description">Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</p>
<p class="achievement-list-page-entry-game">Latin</p>
</div>
<div class="list-page-list-entry">
<img class="achievement-list-page-entry-icon" src="res/dummy_achievement.png" alt="Achievement Icon.png" />
<p class="achievement-list-page-entry-name">Lorem Ipsum</p>
<p class="achievement-list-page-entry-description">Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</p>
<p class="achievement-list-page-entry-game">Latin</p>
</div>
<div class="list-page-list-entry">
<img class="achievement-list-page-entry-icon" src="res/dummy_achievement.png" alt="Achievement Icon.png" />
<p class="achievement-list-page-entry-name">Lorem Ipsum</p>
<p class="achievement-list-page-entry-description">Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</p>
<p class="achievement-list-page-entry-game">Latin</p>
</div>
<div class="list-page-list-entry">
<img class="achievement-list-page-entry-icon" src="res/dummy_achievement.png" alt="Achievement Icon.png" />
<p class="achievement-list-page-entry-name">Lorem Ipsum</p>
<p class="achievement-list-page-entry-description">Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</p>
<p class="achievement-list-page-entry-game">Latin</p>
</div>
${list}
</div>
</div>
</div>

View file

Before

Width:  |  Height:  |  Size: 91 KiB

After

Width:  |  Height:  |  Size: 91 KiB

View file

Before

Width:  |  Height:  |  Size: 113 KiB

After

Width:  |  Height:  |  Size: 113 KiB

View file

Before

Width:  |  Height:  |  Size: 88 KiB

After

Width:  |  Height:  |  Size: 88 KiB

View file

Before

Width:  |  Height:  |  Size: 79 KiB

After

Width:  |  Height:  |  Size: 79 KiB

View file

Before

Width:  |  Height:  |  Size: 41 KiB

After

Width:  |  Height:  |  Size: 41 KiB

View file

Before

Width:  |  Height:  |  Size: 135 KiB

After

Width:  |  Height:  |  Size: 135 KiB