Add scripts to import data
When updating the data, we must manually insert a new catalogue version
This commit is contained in:
67
server/dist/importCharGrowthRates.js
vendored
Normal file
67
server/dist/importCharGrowthRates.js
vendored
Normal file
@ -0,0 +1,67 @@
|
||||
"use strict";
|
||||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
||||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
||||
return new (P || (P = Promise))(function (resolve, reject) {
|
||||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
||||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
||||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
||||
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
||||
});
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
require("dotenv").config();
|
||||
const axios = require('axios').default;
|
||||
const cheerio = require('cheerio');
|
||||
const { CharacterGrowthRate } = require("./mapping");
|
||||
const index_1 = require("./index");
|
||||
const url = "https://serenesforest.net/three-houses/characters/growth-rates/";
|
||||
const mainCharName = "Byleth";
|
||||
const mainCharAlternativeName = "Protagonist";
|
||||
const nameIndex = 0;
|
||||
function importCharGrowthRates() {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
const characters = yield index_1.FE_Charts.getAllCharacters();
|
||||
const stats = yield index_1.FE_Charts.getAllStats();
|
||||
axios.get(url)
|
||||
.then(res => {
|
||||
// We need to remove all line breaks to avoid bad html format
|
||||
const html = res.data.replace(/[\n\r]/g, "");
|
||||
const $ = cheerio.load(html);
|
||||
// parse each tables in the html
|
||||
$("tbody").each(function (i, elem) {
|
||||
// parse each rows of the table
|
||||
elem.children.forEach((row, rowIndex) => {
|
||||
// The first element is the header of the table, so we must skip it
|
||||
if (rowIndex != 0) {
|
||||
let name = $(row.children[nameIndex]).text();
|
||||
if (name == mainCharAlternativeName) {
|
||||
name = mainCharName;
|
||||
}
|
||||
const char = characters.find(x => x.firstName == name);
|
||||
if (char !== undefined) {
|
||||
for (let j = 0; j < stats.length; j++) {
|
||||
const charGrowthRate = new CharacterGrowthRate();
|
||||
charGrowthRate.idCharacter = char.id;
|
||||
charGrowthRate.idStat = stats[j].id;
|
||||
charGrowthRate.value = parseInt($(row.children[j + 1]).text()); // the first col of the table is for the name, so we have to add 1 to the index
|
||||
CharacterGrowthRate.upsert({
|
||||
Id_Character: charGrowthRate.idCharacter,
|
||||
Id_Stat: charGrowthRate.idStat,
|
||||
value: charGrowthRate.value,
|
||||
}).catch(err => index_1.FE_Charts.logError(err));
|
||||
}
|
||||
}
|
||||
else {
|
||||
console.log(`Unknown character ${name}`);
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
})
|
||||
.catch(err => {
|
||||
index_1.FE_Charts.logError(err);
|
||||
});
|
||||
});
|
||||
}
|
||||
importCharGrowthRates();
|
||||
//# sourceMappingURL=importCharGrowthRates.js.map
|
1
server/dist/importCharGrowthRates.js.map
vendored
Normal file
1
server/dist/importCharGrowthRates.js.map
vendored
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"file":"importCharGrowthRates.js","sourceRoot":"","sources":["../src/importCharGrowthRates.ts"],"names":[],"mappings":";;;;;;;;;;;AAAA,OAAO,CAAC,QAAQ,CAAC,CAAC,MAAM,EAAE,CAAC;AAC3B,MAAM,KAAK,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC,OAAO,CAAC;AACvC,MAAM,OAAO,GAAG,OAAO,CAAC,SAAS,CAAC,CAAC;AAEnC,MAAM,EAAC,mBAAmB,EAAC,GAAG,OAAO,CAAC,WAAW,CAAC,CAAC;AACnD,mCAAkC;AAElC,MAAM,GAAG,GAAU,iEAAiE,CAAC;AACrF,MAAM,YAAY,GAAU,QAAQ,CAAC;AACrC,MAAM,uBAAuB,GAAU,aAAa,CAAC;AACrD,MAAM,SAAS,GAAU,CAAC,CAAC;AAG3B,SAAe,qBAAqB;;QAChC,MAAM,UAAU,G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AAK,GAAG,QAAQ,CAAC,CAAC,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,+EAA+E;gCAE/I,mBAAmB,CAAC,MAAM,CAAC;oCACvB,YAAY,EAAE,cAAc,CAAC,WAAW;oCACxC,OAAO,EAAE,cAAc,CAAC,MAAM;oCAC9B,KAAK,EAAE,cAAc,CAAC,KAAK;iCAC9B,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,EAAE,CAAC,iBAAS,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC;6BAC5C;yBACJ;6BAAM;4BACH,OAAO,CAAC,GAAG,CAAC,qBAAqB,IAAI,EAAE,CAAC,CAAC;yBAC5C;qBACJ;gBACL,CAAC,CAAC,CAAC;YACP,CAAC,CAAC,CAAC;QAEP,CAAC,CAAC;aACD,KAAK,CAAC,GAAG,CAAC,EAAE;YACT,iBAAS,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC;QAC5B,CAAC,CAAC,CAAC;IACX,CAAC;CAAA;AAED,qBAAqB,EAAE,CAAC"}
|
64
server/dist/importClassGrowthRates.js
vendored
Normal file
64
server/dist/importClassGrowthRates.js
vendored
Normal file
@ -0,0 +1,64 @@
|
||||
"use strict";
|
||||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
||||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
||||
return new (P || (P = Promise))(function (resolve, reject) {
|
||||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
||||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
||||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
||||
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
||||
});
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
require("dotenv").config();
|
||||
const axios = require('axios').default;
|
||||
const cheerio = require('cheerio');
|
||||
const { ClassGrowthRate } = require("./mapping");
|
||||
const index_1 = require("./index");
|
||||
const url = "https://serenesforest.net/three-houses/classes/growth-rates/";
|
||||
const nameIndex = 0;
|
||||
function importClassGrowthRates() {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
const classes = yield index_1.FE_Charts.getAllClasses();
|
||||
const stats = yield index_1.FE_Charts.getAllStats();
|
||||
axios.get(url)
|
||||
.then(res => {
|
||||
// We need to remove all line breaks to avoid bad html format
|
||||
const html = res.data.replace(/[\n\r]/g, "");
|
||||
const $ = cheerio.load(html);
|
||||
$("#enemy").remove(); // Remove all contents for enemies
|
||||
$("tbody").first().remove(); // Remove the first table who isn't for the growth rates
|
||||
$("tbody").last().remove(); // Remove the last table who is for enemies and not playable character
|
||||
// parse each tables in the html
|
||||
$("tbody").each(function (i, elem) {
|
||||
// parse each rows of the table
|
||||
elem.children.forEach((row, rowIndex) => {
|
||||
// The first element is the header of the table, so we must skip it
|
||||
if (rowIndex != 0) {
|
||||
const name = $(row.children[nameIndex]).text();
|
||||
const feClass = classes.find(x => x.name == name);
|
||||
if (feClass !== undefined) {
|
||||
for (let j = 0; j < stats.length; j++) {
|
||||
const classGrowthRate = new ClassGrowthRate();
|
||||
classGrowthRate.idClass = feClass.id;
|
||||
classGrowthRate.idStat = stats[j].id;
|
||||
classGrowthRate.value = parseInt($(row.children[j + 1]).text()); // the first col of the table is for the name, so we have to add 1 to the index
|
||||
if (classGrowthRate.value) {
|
||||
ClassGrowthRate.upsert({
|
||||
Id_Class: classGrowthRate.idClass,
|
||||
Id_Stat: classGrowthRate.idStat,
|
||||
value: classGrowthRate.value,
|
||||
}).catch(err => index_1.FE_Charts.logError(err));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
})
|
||||
.catch(err => {
|
||||
index_1.FE_Charts.logError(err);
|
||||
});
|
||||
});
|
||||
}
|
||||
importClassGrowthRates();
|
||||
//# sourceMappingURL=importClassGrowthRates.js.map
|
1
server/dist/importClassGrowthRates.js.map
vendored
Normal file
1
server/dist/importClassGrowthRates.js.map
vendored
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"file":"importClassGrowthRates.js","sourceRoot":"","sources":["../src/importClassGrowthRates.ts"],"names":[],"mappings":";;;;;;;;;;;AAAA,OAAO,CAAC,QAAQ,CAAC,CAAC,MAAM,EAAE,CAAC;AAC3B,MAAM,KAAK,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC,OAAO,CAAC;AACvC,MAAM,OAAO,GAAG,OAAO,CAAC,SAAS,CAAC,CAAC;AAEnC,MAAM,EAAC,eAAe,EAAC,GAAG,OAAO,CAAC,WAAW,CAAC,CAAC;AAC/C,mCAAkC;AAElC,MAAM,GAAG,GAAU,8DAA8D,CAAC;AAClF,MAAM,SAAS,GAAU,CAAC,CAAC;AAG3B,SAAe,sBAAsB;;QACjC,MAAM,OAAO,GAAG,MAAM,iBAAS,CAAC,aAAa,EAAE,CAAC;QAChD,MAAM,KAAK,GAAG,MAAM,iBAAS,CAAC,WAAW,EAAE,CAAC;QAC5C,KAAK,CAAC,GAAG,CAAC,GAAG,CAAC;aACT,IAAI,CAAC,GAAG,CAAC,EAAE;YACR,6DAA6D;YAC7D,MAAM,IAAI,GAAG,GAAG,CAAC,IAAI,CAAC,OAAO,CAAC,SAAS,EAAE,EAAE,CAAC,CAAC;YAC7C,MAAM,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;YAE7B,CAAC,CAAC,QAAQ,CAAC,CAAC,MAAM,EAAE,CAAC,CAAC,kCAAkC;YACxD,CAAC,CAAC,OAAO,CAAC,CAAC,KAAK,EAAE,CAAC,MAAM,EAAE,CAAC,CAAC,wDAAwD;YACrF,CAAC,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,CAAC,MAAM,EAAE,CAAC,CAAC,sEAAsE;YAElG,gCAAgC;YAChC,CAAC,CAAC,OAAO,CAAC,CA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ACP,CAAC,CAAC,CAAC;QACP,CAAC,CAAC;aACD,KAAK,CAAC,GAAG,CAAC,EAAE;YACT,iBAAS,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC;QAC5B,CAAC,CAAC,CAAC;IACX,CAAC;CAAA;AAED,sBAAsB,EAAE,CAAC"}
|
106
server/dist/importData.js
vendored
Normal file
106
server/dist/importData.js
vendored
Normal file
@ -0,0 +1,106 @@
|
||||
"use strict";
|
||||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
||||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
||||
return new (P || (P = Promise))(function (resolve, reject) {
|
||||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
||||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
||||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
||||
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
||||
});
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
require("dotenv").config();
|
||||
const axios = require('axios').default;
|
||||
const cheerio = require('cheerio');
|
||||
const { Catalogue, Character, CharacterGrowthRate, ClassGrowthRate, FE_Class, Gender, House, Stat, RestrictedCharacterClass } = require("./mapping");
|
||||
const index_1 = require("./index");
|
||||
function importCharGrowthRates() {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
const characters = yield index_1.FE_Charts.getAllCharacters();
|
||||
const stats = yield index_1.FE_Charts.getAllStats();
|
||||
axios.get("https://serenesforest.net/three-houses/characters/growth-rates/")
|
||||
.then(res => {
|
||||
// We need to remove all line breaks to avoid bad html format
|
||||
const html = res.data.replace(/[\n\r]/g, "");
|
||||
const $ = cheerio.load(html);
|
||||
// parse each tables in the html
|
||||
$("tbody").each(function (i, elem) {
|
||||
// parse each rows of the table
|
||||
elem.children.forEach((row, rowIndex) => {
|
||||
// The first element is the header of the table, so we must skip it
|
||||
if (rowIndex != 0) {
|
||||
let name = $(row.children[0]).text();
|
||||
if (name == "Protagonist") {
|
||||
name = "Byleth";
|
||||
}
|
||||
const char = characters.find(x => x.firstName == name);
|
||||
if (char !== undefined) {
|
||||
for (let j = 0; j < stats.length; j++) {
|
||||
const charGrowthRate = new CharacterGrowthRate();
|
||||
charGrowthRate.idCharacter = char.id;
|
||||
charGrowthRate.idStat = stats[j].id;
|
||||
charGrowthRate.value = parseInt($(row.children[j + 1]).text()); // the first col of the table is for the name, so we have to add 1 to the index
|
||||
CharacterGrowthRate.upsert({
|
||||
Id_Character: charGrowthRate.idCharacter,
|
||||
Id_Stat: charGrowthRate.idStat,
|
||||
value: charGrowthRate.value,
|
||||
}).catch(err => index_1.FE_Charts.logError(err));
|
||||
}
|
||||
}
|
||||
else {
|
||||
console.log(`Unknown character ${name}`);
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
})
|
||||
.catch(err => {
|
||||
index_1.FE_Charts.logError(err);
|
||||
});
|
||||
});
|
||||
}
|
||||
function importClassGrowthRates() {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
const classes = yield index_1.FE_Charts.getAllClasses();
|
||||
const stats = yield index_1.FE_Charts.getAllStats();
|
||||
axios.get("https://serenesforest.net/three-houses/classes/growth-rates/")
|
||||
.then(res => {
|
||||
// We need to remove all line breaks to avoid bad html format
|
||||
const html = res.data.replace(/[\n\r]/g, "");
|
||||
const $ = cheerio.load(html);
|
||||
$("#enemy").remove(); // Remove all contents for enemies
|
||||
$("tbody").first().remove(); // Remove the first table who isn't for the growth rates
|
||||
$("tbody").last().remove(); // Remove the last table who is for enemies and not playable character
|
||||
// parse each tables in the html
|
||||
$("tbody").each(function (i, elem) {
|
||||
// parse each rows of the table
|
||||
elem.children.forEach((row, rowIndex) => {
|
||||
// The first element is the header of the table, so we must skip it
|
||||
if (rowIndex != 0) {
|
||||
const name = $(row.children[0]).text();
|
||||
const feClass = classes.find(x => x.name == name);
|
||||
if (feClass !== undefined) {
|
||||
for (let j = 0; j < stats.length; j++) {
|
||||
const classGrowthRate = new ClassGrowthRate();
|
||||
classGrowthRate.idClass = feClass.id;
|
||||
classGrowthRate.idStat = stats[j].id;
|
||||
classGrowthRate.value = parseInt($(row.children[j + 1]).text()); // the first col of the table is for the name, so we have to add 1 to the index
|
||||
if (classGrowthRate.value) {
|
||||
ClassGrowthRate.upsert({
|
||||
Id_Class: classGrowthRate.idClass,
|
||||
Id_Stat: classGrowthRate.idStat,
|
||||
value: classGrowthRate.value,
|
||||
}).catch(err => index_1.FE_Charts.logError(err));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
})
|
||||
.catch(err => {
|
||||
index_1.FE_Charts.logError(err);
|
||||
});
|
||||
});
|
||||
}
|
||||
//# sourceMappingURL=importData.js.map
|
1
server/dist/importData.js.map
vendored
Normal file
1
server/dist/importData.js.map
vendored
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"file":"importData.js","sourceRoot":"","sources":["../src/importData.ts"],"names":[],"mappings":";;;;;;;;;;;AAAA,OAAO,CAAC,QAAQ,CAAC,CAAC,MAAM,EAAE,CAAC;AAC3B,MAAM,KAAK,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC,OAAO,CAAC;AACvC,MAAM,OAAO,GAAG,OAAO,CAAC,SAAS,CAAC,CAAC;AAEnC,MAAM,EAAC,SAAS,EAAE,SAAS,EAAE,mBAAmB,EAAE,eAAe,EAAE,QAAQ,EAAE,MAAM,EAAE,KAAK,EAAE,IAAI,EAAE,wBAAwB,EAAC,GAAG,OAAO,CAAC,WAAW,CAAC,CAAC;AACnJ,mCAAkC;AAElC,SAAe,qBAAqB;;QAChC,MAAM,UAAU,GAAG,MAAM,iBAAS,CAAC,gBAAgB,EAAE,CAAC;QACtD,MAAM,KAAK,GAAG,MAAM,iBAAS,CAAC,WAAW,EAAE,CAAC;QAC5C,KAAK,CAAC,GAAG,CAAC,iEAAiE,CAAC;aACvE,IAAI,CAA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AAC,CAAC;aACD,KAAK,CAAC,GAAG,CAAC,EAAE;YACT,iBAAS,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC;QAC5B,CAAC,CAAC,CAAC;IACX,CAAC;CAAA"}
|
139
server/dist/index.js
vendored
139
server/dist/index.js
vendored
@ -1,11 +1,24 @@
|
||||
"use strict";
|
||||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
||||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
||||
return new (P || (P = Promise))(function (resolve, reject) {
|
||||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
||||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
||||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
||||
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
||||
});
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
require("dotenv").config();
|
||||
const axios = require('axios').default;
|
||||
const cheerio = require('cheerio');
|
||||
const express = require("express");
|
||||
const bodyParser = require("body-parser");
|
||||
require("./mapping");
|
||||
const status = require("http-status");
|
||||
const { Catalogue, Character, CharacterGrowthRate, ClassGrowthRate, FE_Class, Gender, House, Stat, RestrictedCharacterClass } = require("./mapping");
|
||||
const app = express();
|
||||
const port = process.env.NODE_PORT || 3000;
|
||||
const argImport = "importing";
|
||||
app.use(bodyParser.urlencoded({ extended: false }));
|
||||
app.use(bodyParser.json());
|
||||
app.use(function (req, res, next) {
|
||||
@ -15,10 +28,130 @@ app.use(function (req, res, next) {
|
||||
res.header("Access-Control-Allow-Headers", "Origin, X-Requested-With, Content-Type, Accept");
|
||||
next();
|
||||
});
|
||||
class FE_Charts {
|
||||
static logError(err) {
|
||||
// TODO: Log to file and manage the error
|
||||
console.log(err);
|
||||
}
|
||||
static getAllCharacters() {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
let characters = null;
|
||||
yield Character.findAll().then(results => {
|
||||
characters = results;
|
||||
}).catch(err => FE_Charts.logError(err));
|
||||
return characters;
|
||||
});
|
||||
}
|
||||
static getAllCharactersGrowthRates() {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
let charactersGrowRates = null;
|
||||
yield CharacterGrowthRate.findAll().then(results => {
|
||||
charactersGrowRates = results;
|
||||
}).catch(err => FE_Charts.logError(err));
|
||||
return charactersGrowRates;
|
||||
});
|
||||
}
|
||||
static getAllClassesGrowthRates() {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
let classesGrowRates = null;
|
||||
yield ClassGrowthRate.findAll().then(results => {
|
||||
classesGrowRates = results;
|
||||
}).catch(err => FE_Charts.logError(err));
|
||||
return classesGrowRates;
|
||||
});
|
||||
}
|
||||
static getAllClasses() {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
let classes = null;
|
||||
yield FE_Class.findAll().then(results => {
|
||||
classes = results;
|
||||
}).catch(err => FE_Charts.logError(err));
|
||||
return classes;
|
||||
});
|
||||
}
|
||||
static getAllGenders() {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
let genders = null;
|
||||
yield Gender.findAll().then(results => {
|
||||
genders = results;
|
||||
}).catch(err => FE_Charts.logError(err));
|
||||
return genders;
|
||||
});
|
||||
}
|
||||
static getAllHouses() {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
let houses = null;
|
||||
yield House.findAll().then(results => {
|
||||
houses = results;
|
||||
}).catch(err => FE_Charts.logError(err));
|
||||
return houses;
|
||||
});
|
||||
}
|
||||
static getAllRestrictedClasses() {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
let restrictedClasses = null;
|
||||
yield RestrictedCharacterClass.findAll().then(results => {
|
||||
restrictedClasses = results;
|
||||
}).catch(err => FE_Charts.logError(err));
|
||||
return restrictedClasses;
|
||||
});
|
||||
}
|
||||
static getAllStats() {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
let stats = null;
|
||||
yield Stat.findAll().then(results => {
|
||||
stats = results;
|
||||
}).catch(err => FE_Charts.logError(err));
|
||||
return stats;
|
||||
});
|
||||
}
|
||||
static getCatalogueLastVersion() {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
let version = null;
|
||||
yield Catalogue.findAll({
|
||||
attributes: ["version", ["Dttm_Last_Update", "lastUpdate"]],
|
||||
limit: 1,
|
||||
order: [["Dttm_Last_Update", "DESC"]],
|
||||
}).then(results => {
|
||||
version = results;
|
||||
}).catch(err => FE_Charts.logError(err));
|
||||
return version;
|
||||
});
|
||||
}
|
||||
}
|
||||
exports.FE_Charts = FE_Charts;
|
||||
app.get('/', (req, res) => {
|
||||
res.send('Hello World!');
|
||||
});
|
||||
app.listen(port, () => {
|
||||
console.log(`Example app listening on port ${port}!`);
|
||||
app.get('/version', (req, res) => {
|
||||
FE_Charts.getCatalogueLastVersion().then(version => {
|
||||
res.status(status.OK).send(version);
|
||||
});
|
||||
});
|
||||
app.get('/all', (req, res) => __awaiter(void 0, void 0, void 0, function* () {
|
||||
const characters = yield FE_Charts.getAllCharacters();
|
||||
const characterGrowthRates = yield FE_Charts.getAllCharactersGrowthRates();
|
||||
const classesGrowthRates = yield FE_Charts.getAllClassesGrowthRates();
|
||||
const classes = yield FE_Charts.getAllClasses();
|
||||
const genders = yield FE_Charts.getAllGenders();
|
||||
const houses = yield FE_Charts.getAllHouses();
|
||||
const restrictedClasses = yield FE_Charts.getAllRestrictedClasses();
|
||||
const stats = yield FE_Charts.getAllStats();
|
||||
res.status(status.OK).send({
|
||||
characters: characters,
|
||||
charGrowthRates: characterGrowthRates,
|
||||
classGrowthRates: classesGrowthRates,
|
||||
classes: classes,
|
||||
genders: genders,
|
||||
houses: houses,
|
||||
restrictedClasses: restrictedClasses,
|
||||
stats: stats,
|
||||
});
|
||||
}));
|
||||
// Don't start the server if we're importing some data
|
||||
if (process.argv.find(x => x == argImport) == undefined) {
|
||||
app.listen(port, () => {
|
||||
console.log(`Example app listening on port ${port}!`);
|
||||
});
|
||||
}
|
||||
//# sourceMappingURL=index.js.map
|
2
server/dist/index.js.map
vendored
2
server/dist/index.js.map
vendored
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user