+ Moved client to subfolder and added db communication

This commit is contained in:
Alexis
2020-03-20 21:05:28 +01:00
parent c08e07f7b6
commit ef9e98641a
24 changed files with 13069 additions and 12559 deletions

3
.gitignore vendored
View File

@@ -19,3 +19,6 @@ yarn-error.log*
*.njsproj *.njsproj
*.sln *.sln
*.sw? *.sw?
# creds
/database/credentials.json

12563
client/package-lock.json generated Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -1,7 +1,7 @@
{ {
"name": "spellsaurus", "name": "spellsaurus_client",
"version": "1.0.0", "version": "1.0.0",
"description": "A dictionnary of arcane spells from a homebrew tabletop RPG.", "description": "The client interface of spellsaurus",
"keywords": [ "keywords": [
"rpg", "rpg",
"dev", "dev",
@@ -37,7 +37,6 @@
"babel-eslint": "^10.0.3", "babel-eslint": "^10.0.3",
"eslint": "^6.7.2", "eslint": "^6.7.2",
"eslint-plugin-vue": "^6.1.2", "eslint-plugin-vue": "^6.1.2",
"express": "^4.17.1",
"node-sass": "^4.13.1", "node-sass": "^4.13.1",
"sass-loader": "^8.0.2", "sass-loader": "^8.0.2",
"vue-router": "^3.1.6", "vue-router": "^3.1.6",

View File

Before

Width:  |  Height:  |  Size: 4.2 KiB

After

Width:  |  Height:  |  Size: 4.2 KiB

View File

Before

Width:  |  Height:  |  Size: 6.7 KiB

After

Width:  |  Height:  |  Size: 6.7 KiB

View File

@@ -7,6 +7,9 @@ import spells from "./pages/spells";
// Routes // Routes
const routes = [ const routes = [
{
path: "*", redirect: "/",
},
{ {
path: '/', component: index, path: '/', component: index,
}, },

16
connection.js Normal file
View File

@@ -0,0 +1,16 @@
// MODULES
const fs = require('fs');
const mysql = require('mysql');
// Fetches and parses credentials file
let credentials_data = fs.readFileSync('./database/credentials.json');
let credentials = JSON.parse(credentials_data);
const db = mysql.createConnection({
host: credentials.host,
user: credentials.user,
password: credentials.password,
database: credentials.database,
})
module.exports = { db }

View File

@@ -1,3 +1,14 @@
DROP USER IF EXISTS 'archivist'@'%';
CREATE USER 'archivist'@'%'
IDENTIFIED BY 'root';
GRANT ALL
ON spellsaurus.*
TO 'archivist'@'%';
FLUSH PRIVILEGES;
DROP DATABASE IF EXISTS spellsaurus; DROP DATABASE IF EXISTS spellsaurus;
CREATE DATABASE spellsaurus; CREATE DATABASE spellsaurus;
USE spellsaurus; USE spellsaurus;

26
index.js Normal file
View File

@@ -0,0 +1,26 @@
// MODULES
const express = require('express');
let connection = require('./connection');
const db = connection.db;
// CONSTANTS
const port = 2814;
const query = "SELECT * FROM spell";
// make to connection to the database.
db.connect( err => {
if (err) { throw err }
console.log("Connected");
db.query(query, (err, result, fields) => {
console.log(result[0]);
});
});
app = express();
app.listen(port, () => {
console.log(`App listening on port ${port}`)
});

13001
package-lock.json generated

File diff suppressed because it is too large Load Diff