Update server.js

master
sigonasr2 3 years ago
commit 227f4a79a5
  1. 2
      Dockerfile
  2. 20
      ngsplanner_patch.sql
  3. 38
      ngsplanner_schema.sql
  4. 96
      ngsplanner_seed.sql
  5. 31
      patch_old/2021-08-09-ngsplanner_patch.sql
  6. 204
      server_test.js

@ -35,6 +35,6 @@ ADD https://github.com/krallin/tini/releases/download/${TINI_VERSION}/tini /tini
RUN chmod +x /tini
ENTRYPOINT ["/tini", "--"]
EXPOSE 3006
EXPOSE 3007
CMD [ "nodemon", "server.js" ]

@ -1,15 +1,5 @@
/*9 Aug Database Patch*/
alter table potential add column description text;
alter table weapon_existence_data add column icon text;
alter table weapon_type add column shorthand text;
alter table weapon_existence_data add column special_name text;
alter table potential drop column description;
alter table potential_data add column description text;
alter table photon_art add column icon text;
alter table users add column recovery_hash text;
alter table armor rename column pb_gauge_build to slot;
alter table armor add column battle_power_value text;
CREATE TABLE "skill_tree_data"("id" SERIAL UNIQUE PRIMARY KEY,"class_id" int,"data" text,"skill_data" text,"line_color" text,"line_width" int,"gridsizex" int,"gridsizey" int,"gridpaddingx" int,"gridpaddingy" int);
ALTER TABLE "skill_tree_data" ADD FOREIGN KEY ("class_id") REFERENCES "class" ("id");
alter table skill_tree_data add column halflineheight int;
CREATE TABLE "site_data" ("id" SERIAL UNIQUE PRIMARY KEY,"field" text,"data" text);
/*27 Aug Database Patch*/
CREATE TABLE "element" ("id" SERIAL UNIQUE PRIMARY KEY,"name" text);
alter table augment add column element_id int;
alter table augment add column icon text;
alter table augment_type drop column icon;

@ -14,6 +14,8 @@ CREATE TABLE "food_mult" (
CREATE TABLE "food" (
"id" SERIAL UNIQUE PRIMARY KEY,
"name" text,
"description" text,
"icon" text,
"potency" boolean,
"pp" boolean,
"dmg_res" boolean,
@ -117,7 +119,7 @@ CREATE TABLE "armor" (
"crit_dmg" float,
"pp_cost_reduction" float,
"active_pp_recovery" float,
"natural_pp_recovery" float,
"natural_pp_recovery" text,
"dmg_res" float,
"all_down_res" float,
"burn_res" float,
@ -160,7 +162,8 @@ CREATE TABLE "augment" (
"battle_power_value" int,
"pb_gauge_build" float,
"popularity" int,
"editors_choice" int
"editors_choice" int,
"element_id" int
);
CREATE TABLE "skill" (
@ -247,20 +250,20 @@ CREATE TABLE "class_skill_data" (
"effect" text,
"duration" int,
"cooldown" int,
"damage_taken" float,
"pa_potency" float,
"damage_taken" text,
"pa_potency" text,
"conditional_buff" boolean,
"pp_recovery" float,
"pp_recovery" text,
"property" text,
"all_damage_buff" float,
"active_pp_recovery" float,
"status_ailment_accum" float,
"status_ailment_duration" float,
"pp_consumption" float,
"max_hp_decrease" float,
"natural_pp_recovery" float,
"all_damage_buff" text,
"active_pp_recovery" text,
"status_ailment_accum" text,
"status_ailment_duration" text,
"pp_consumption" text,
"max_hp_decrease" text,
"natural_pp_recovery" text,
"added_pp" int,
"pb_gauge_fortification" float
"pb_gauge_fortification" text
);
CREATE TABLE "database_audit" (
@ -322,10 +325,15 @@ CREATE TABLE "skill_tree_data" (
CREATE TABLE "site_data" (
"id" SERIAL UNIQUE PRIMARY KEY,
"field" text,
"name" text,
"data" text
);
CREATE TABLE "element" (
"id" SERIAL UNIQUE PRIMARY KEY,
"name" text
);
ALTER TABLE "builds" ADD FOREIGN KEY ("users_id") REFERENCES "users" ("id");
ALTER TABLE "users" ADD FOREIGN KEY ("roles_id") REFERENCES "roles" ("id");
@ -363,3 +371,5 @@ ALTER TABLE "builds" ADD FOREIGN KEY ("class1") REFERENCES "class" ("id");
ALTER TABLE "builds" ADD FOREIGN KEY ("class2") REFERENCES "class" ("id");
ALTER TABLE "skill_tree_data" ADD FOREIGN KEY ("class_id") REFERENCES "class" ("id");
ALTER TABLE "augment" ADD FOREIGN KEY ("element_id") REFERENCES "element" ("id");

@ -8,6 +8,7 @@ delete from food_mult;
delete from food;
delete from armor;
delete from augment;
delete from element;
delete from augment_type;
delete from skill_data;
delete from skill;
@ -29,10 +30,10 @@ insert into food_mult(amount,potency,pp,dmg_res,hp,pp_consumption,pp_recovery,we
insert into food_mult(amount,potency,pp,dmg_res,hp,pp_consumption,pp_recovery,weak_point_dmg,hp_recovery)
values(1,1.05,10,1.05,1.05,1,1,1,1);
insert into food(name,potency,pp,dmg_res,hp,pp_consumption,pp_recovery,weak_point_dmg,hp_recovery,popularity,editors_choice)
values('Rich Aelio Meat',true,false,false,false,true,false,false,false,0,0);
insert into food(name,potency,pp,dmg_res,hp,pp_consumption,pp_recovery,weak_point_dmg,hp_recovery,popularity,editors_choice)
values('Light Aelio Meat',true,false,false,false,false,true,false,false,0,0);
insert into food(name,description,icon,potency,pp,dmg_res,hp,pp_consumption,pp_recovery,weak_point_dmg,hp_recovery,popularity,editors_choice)
values('Rich Aelio Meat','Meat','',true,false,false,false,true,false,false,false,0,0);
insert into food(name,description,icon,potency,pp,dmg_res,hp,pp_consumption,pp_recovery,weak_point_dmg,hp_recovery,popularity,editors_choice)
values('Light Aelio Meat','Meat','',true,false,false,false,false,true,false,false,0,0);
insert into class(name,icon) values('Hunter','/icons/UINGSClassHu.png');
insert into class(name,icon) values('Fighter','/icons/UINGSClassFi.png');
@ -200,39 +201,52 @@ insert into skill_data(skill_id,name,level,variance,mel_dmg,rng_dmg,tec_dmg,crit
insert into skill_data(skill_id,name,level,variance,mel_dmg,rng_dmg,tec_dmg,crit_rate,crit_dmg,pp_cost_reduction,active_pp_recovery,natural_pp_recovery,dmg_res,popularity,editors_choice)
values((select id from skill where name='Fixa Termina' limit 1),'Fixa Termina Lv.3',3,0,0,0,0,0,1.10,0,0,0,0,0,0);
insert into augment_type(name,icon)
values('Stamina','');
insert into augment_type(name,icon)
values('Spirit','');
insert into augment_type(name,icon)
values('Might','');
insert into augment_type(name,icon)
values('Precision','');
insert into element(name)
values('None');
insert into element(name)
values('Fire');
insert into element(name)
values('Ice');
insert into element(name)
values('Lightning');
insert into augment(augment_type_id,name,variance,hp,pp,mel_dmg,rng_dmg,tec_dmg,crit_rate,crit_dmg,pp_cost_reduction,active_pp_recovery,natural_pp_recovery,dmg_res,affix_success_rate,all_down_res,burn_res,freeze_res,blind_res,shock_res,panic_res,poison_res,battle_power_value,pb_gauge_build,popularity,editors_choice)
values((select id from augment_type where name='Stamina' limit 1),1,0,5,0,0,0,0,0,0,0,0,0,0,0.1,0,0,0,0,0,0,0,3,0,0,0);
insert into augment(augment_type_id,name,variance,hp,pp,mel_dmg,rng_dmg,tec_dmg,crit_rate,crit_dmg,pp_cost_reduction,active_pp_recovery,natural_pp_recovery,dmg_res,affix_success_rate,all_down_res,burn_res,freeze_res,blind_res,shock_res,panic_res,poison_res,battle_power_value,pb_gauge_build,popularity,editors_choice)
values((select id from augment_type where name='Stamina' limit 1),2,0,10,0,0,0,0,0,0,0,0,0,0,0.1,0,0,0,0,0,0,0,4,0,0,0);
insert into augment(augment_type_id,name,variance,hp,pp,mel_dmg,rng_dmg,tec_dmg,crit_rate,crit_dmg,pp_cost_reduction,active_pp_recovery,natural_pp_recovery,dmg_res,affix_success_rate,all_down_res,burn_res,freeze_res,blind_res,shock_res,panic_res,poison_res,battle_power_value,pb_gauge_build,popularity,editors_choice)
values((select id from augment_type where name='Stamina' limit 1),3,0,15,0,0,0,0,0,0,0,0,0,0,0.09,0,0,0,0,0,0,0,5,0,0,0);
insert into augment(augment_type_id,name,variance,hp,pp,mel_dmg,rng_dmg,tec_dmg,crit_rate,crit_dmg,pp_cost_reduction,active_pp_recovery,natural_pp_recovery,dmg_res,affix_success_rate,all_down_res,burn_res,freeze_res,blind_res,shock_res,panic_res,poison_res,battle_power_value,pb_gauge_build,popularity,editors_choice)
values((select id from augment_type where name='Spirit' limit 1),1,0,0,3,0,0,0,0,0,0,0,0,0,0.1,0,0,0,0,0,0,0,2,0,0,0);
insert into augment(augment_type_id,name,variance,hp,pp,mel_dmg,rng_dmg,tec_dmg,crit_rate,crit_dmg,pp_cost_reduction,active_pp_recovery,natural_pp_recovery,dmg_res,affix_success_rate,all_down_res,burn_res,freeze_res,blind_res,shock_res,panic_res,poison_res,battle_power_value,pb_gauge_build,popularity,editors_choice)
values((select id from augment_type where name='Spirit' limit 1),2,0,0,4,0,0,0,0,0,0,0,0,0,0.1,0,0,0,0,0,0,0,3,0,0,0);
insert into augment(augment_type_id,name,variance,hp,pp,mel_dmg,rng_dmg,tec_dmg,crit_rate,crit_dmg,pp_cost_reduction,active_pp_recovery,natural_pp_recovery,dmg_res,affix_success_rate,all_down_res,burn_res,freeze_res,blind_res,shock_res,panic_res,poison_res,battle_power_value,pb_gauge_build,popularity,editors_choice)
values((select id from augment_type where name='Spirit' limit 1),3,0,0,5,0,0,0,0,0,0,0,0,0,0.09,0,0,0,0,0,0,0,4,0,0,0);
insert into augment(augment_type_id,name,variance,hp,pp,mel_dmg,rng_dmg,tec_dmg,crit_rate,crit_dmg,pp_cost_reduction,active_pp_recovery,natural_pp_recovery,dmg_res,affix_success_rate,all_down_res,burn_res,freeze_res,blind_res,shock_res,panic_res,poison_res,battle_power_value,pb_gauge_build,popularity,editors_choice)
values((select id from augment_type where name='Might' limit 1),1,0,0,0,1.01,0,0,0,0,0,0,0,0,0.1,0,0,0,0,0,0,0,4,0,0,0);
insert into augment(augment_type_id,name,variance,hp,pp,mel_dmg,rng_dmg,tec_dmg,crit_rate,crit_dmg,pp_cost_reduction,active_pp_recovery,natural_pp_recovery,dmg_res,affix_success_rate,all_down_res,burn_res,freeze_res,blind_res,shock_res,panic_res,poison_res,battle_power_value,pb_gauge_build,popularity,editors_choice)
values((select id from augment_type where name='Might' limit 1),2,0,0,0,1.015,0,0,0,0,0,0,0,0,0.1,0,0,0,0,0,0,0,5,0,0,0);
insert into augment(augment_type_id,name,variance,hp,pp,mel_dmg,rng_dmg,tec_dmg,crit_rate,crit_dmg,pp_cost_reduction,active_pp_recovery,natural_pp_recovery,dmg_res,affix_success_rate,all_down_res,burn_res,freeze_res,blind_res,shock_res,panic_res,poison_res,battle_power_value,pb_gauge_build,popularity,editors_choice)
values((select id from augment_type where name='Might' limit 1),3,0,0,0,1.02,0,0,0,0,0,0,0,0,0.09,0,0,0,0,0,0,0,6,0,0,0);
insert into augment(augment_type_id,name,variance,hp,pp,mel_dmg,rng_dmg,tec_dmg,crit_rate,crit_dmg,pp_cost_reduction,active_pp_recovery,natural_pp_recovery,dmg_res,affix_success_rate,all_down_res,burn_res,freeze_res,blind_res,shock_res,panic_res,poison_res,battle_power_value,pb_gauge_build,popularity,editors_choice)
values((select id from augment_type where name='Precision' limit 1),1,0,0,0,0,1.01,0,0,0,0,0,0,0,0.1,0,0,0,0,0,0,0,4,0,0,0);
insert into augment(augment_type_id,name,variance,hp,pp,mel_dmg,rng_dmg,tec_dmg,crit_rate,crit_dmg,pp_cost_reduction,active_pp_recovery,natural_pp_recovery,dmg_res,affix_success_rate,all_down_res,burn_res,freeze_res,blind_res,shock_res,panic_res,poison_res,battle_power_value,pb_gauge_build,popularity,editors_choice)
values((select id from augment_type where name='Precision' limit 1),2,0,0,0,0,1.015,0,0,0,0,0,0,0,0.1,0,0,0,0,0,0,0,5,0,0,0);
insert into augment(augment_type_id,name,variance,hp,pp,mel_dmg,rng_dmg,tec_dmg,crit_rate,crit_dmg,pp_cost_reduction,active_pp_recovery,natural_pp_recovery,dmg_res,affix_success_rate,all_down_res,burn_res,freeze_res,blind_res,shock_res,panic_res,poison_res,battle_power_value,pb_gauge_build,popularity,editors_choice)
values((select id from augment_type where name='Precision' limit 1),3,0,0,0,0,1.02,0,0,0,0,0,0,0,0.09,0,0,0,0,0,0,0,6,0,0,0);
insert into augment_type(name)
values('Stamina');
insert into augment_type(name)
values('Spirit');
insert into augment_type(name)
values('Might');
insert into augment_type(name)
values('Precision');
insert into augment_type(name)
values('Ice Weakness');
insert into augment(augment_type_id,name,variance,hp,pp,mel_dmg,rng_dmg,tec_dmg,crit_rate,crit_dmg,pp_cost_reduction,active_pp_recovery,natural_pp_recovery,dmg_res,affix_success_rate,all_down_res,burn_res,freeze_res,blind_res,shock_res,panic_res,poison_res,battle_power_value,pb_gauge_build,popularity,editors_choice,element_id,icon)
values((select id from augment_type where name='Stamina' limit 1),1,0,5,0,0,0,0,0,0,0,0,0,0,0.1,0,0,0,0,0,0,0,3,0,0,0,(select id from element where name='None' limit 1),'');
insert into augment(augment_type_id,name,variance,hp,pp,mel_dmg,rng_dmg,tec_dmg,crit_rate,crit_dmg,pp_cost_reduction,active_pp_recovery,natural_pp_recovery,dmg_res,affix_success_rate,all_down_res,burn_res,freeze_res,blind_res,shock_res,panic_res,poison_res,battle_power_value,pb_gauge_build,popularity,editors_choice,element_id,icon)
values((select id from augment_type where name='Stamina' limit 1),2,0,10,0,0,0,0,0,0,0,0,0,0,0.1,0,0,0,0,0,0,0,4,0,0,0,(select id from element where name='None' limit 1),'');
insert into augment(augment_type_id,name,variance,hp,pp,mel_dmg,rng_dmg,tec_dmg,crit_rate,crit_dmg,pp_cost_reduction,active_pp_recovery,natural_pp_recovery,dmg_res,affix_success_rate,all_down_res,burn_res,freeze_res,blind_res,shock_res,panic_res,poison_res,battle_power_value,pb_gauge_build,popularity,editors_choice,element_id,icon)
values((select id from augment_type where name='Stamina' limit 1),3,0,15,0,0,0,0,0,0,0,0,0,0,0.09,0,0,0,0,0,0,0,5,0,0,0,(select id from element where name='None' limit 1),'');
insert into augment(augment_type_id,name,variance,hp,pp,mel_dmg,rng_dmg,tec_dmg,crit_rate,crit_dmg,pp_cost_reduction,active_pp_recovery,natural_pp_recovery,dmg_res,affix_success_rate,all_down_res,burn_res,freeze_res,blind_res,shock_res,panic_res,poison_res,battle_power_value,pb_gauge_build,popularity,editors_choice,element_id,icon)
values((select id from augment_type where name='Spirit' limit 1),1,0,0,3,0,0,0,0,0,0,0,0,0,0.1,0,0,0,0,0,0,0,2,0,0,0,(select id from element where name='None' limit 1),'');
insert into augment(augment_type_id,name,variance,hp,pp,mel_dmg,rng_dmg,tec_dmg,crit_rate,crit_dmg,pp_cost_reduction,active_pp_recovery,natural_pp_recovery,dmg_res,affix_success_rate,all_down_res,burn_res,freeze_res,blind_res,shock_res,panic_res,poison_res,battle_power_value,pb_gauge_build,popularity,editors_choice,element_id,icon)
values((select id from augment_type where name='Spirit' limit 1),2,0,0,4,0,0,0,0,0,0,0,0,0,0.1,0,0,0,0,0,0,0,3,0,0,0,(select id from element where name='None' limit 1),'');
insert into augment(augment_type_id,name,variance,hp,pp,mel_dmg,rng_dmg,tec_dmg,crit_rate,crit_dmg,pp_cost_reduction,active_pp_recovery,natural_pp_recovery,dmg_res,affix_success_rate,all_down_res,burn_res,freeze_res,blind_res,shock_res,panic_res,poison_res,battle_power_value,pb_gauge_build,popularity,editors_choice,element_id,icon)
values((select id from augment_type where name='Spirit' limit 1),3,0,0,5,0,0,0,0,0,0,0,0,0,0.09,0,0,0,0,0,0,0,4,0,0,0,(select id from element where name='None' limit 1),'');
insert into augment(augment_type_id,name,variance,hp,pp,mel_dmg,rng_dmg,tec_dmg,crit_rate,crit_dmg,pp_cost_reduction,active_pp_recovery,natural_pp_recovery,dmg_res,affix_success_rate,all_down_res,burn_res,freeze_res,blind_res,shock_res,panic_res,poison_res,battle_power_value,pb_gauge_build,popularity,editors_choice,element_id,icon)
values((select id from augment_type where name='Might' limit 1),1,0,0,0,1.01,0,0,0,0,0,0,0,0,0.1,0,0,0,0,0,0,0,4,0,0,0,(select id from element where name='None' limit 1),'');
insert into augment(augment_type_id,name,variance,hp,pp,mel_dmg,rng_dmg,tec_dmg,crit_rate,crit_dmg,pp_cost_reduction,active_pp_recovery,natural_pp_recovery,dmg_res,affix_success_rate,all_down_res,burn_res,freeze_res,blind_res,shock_res,panic_res,poison_res,battle_power_value,pb_gauge_build,popularity,editors_choice,element_id,icon)
values((select id from augment_type where name='Might' limit 1),2,0,0,0,1.015,0,0,0,0,0,0,0,0,0.1,0,0,0,0,0,0,0,5,0,0,0,(select id from element where name='None' limit 1),'');
insert into augment(augment_type_id,name,variance,hp,pp,mel_dmg,rng_dmg,tec_dmg,crit_rate,crit_dmg,pp_cost_reduction,active_pp_recovery,natural_pp_recovery,dmg_res,affix_success_rate,all_down_res,burn_res,freeze_res,blind_res,shock_res,panic_res,poison_res,battle_power_value,pb_gauge_build,popularity,editors_choice,element_id,icon)
values((select id from augment_type where name='Might' limit 1),3,0,0,0,1.02,0,0,0,0,0,0,0,0,0.09,0,0,0,0,0,0,0,6,0,0,0,(select id from element where name='None' limit 1),'');
insert into augment(augment_type_id,name,variance,hp,pp,mel_dmg,rng_dmg,tec_dmg,crit_rate,crit_dmg,pp_cost_reduction,active_pp_recovery,natural_pp_recovery,dmg_res,affix_success_rate,all_down_res,burn_res,freeze_res,blind_res,shock_res,panic_res,poison_res,battle_power_value,pb_gauge_build,popularity,editors_choice,element_id,icon)
values((select id from augment_type where name='Precision' limit 1),1,0,0,0,0,1.01,0,0,0,0,0,0,0,0.1,0,0,0,0,0,0,0,4,0,0,0,(select id from element where name='None' limit 1),'');
insert into augment(augment_type_id,name,variance,hp,pp,mel_dmg,rng_dmg,tec_dmg,crit_rate,crit_dmg,pp_cost_reduction,active_pp_recovery,natural_pp_recovery,dmg_res,affix_success_rate,all_down_res,burn_res,freeze_res,blind_res,shock_res,panic_res,poison_res,battle_power_value,pb_gauge_build,popularity,editors_choice,element_id,icon)
values((select id from augment_type where name='Precision' limit 1),2,0,0,0,0,1.015,0,0,0,0,0,0,0,0.1,0,0,0,0,0,0,0,5,0,0,0,(select id from element where name='None' limit 1),'');
insert into augment(augment_type_id,name,variance,hp,pp,mel_dmg,rng_dmg,tec_dmg,crit_rate,crit_dmg,pp_cost_reduction,active_pp_recovery,natural_pp_recovery,dmg_res,affix_success_rate,all_down_res,burn_res,freeze_res,blind_res,shock_res,panic_res,poison_res,battle_power_value,pb_gauge_build,popularity,editors_choice,element_id,icon)
values((select id from augment_type where name='Precision' limit 1),3,0,0,0,0,1.02,0,0,0,0,0,0,0,0.09,0,0,0,0,0,0,0,6,0,0,0,(select id from element where name='None' limit 1),'');
insert into augment(augment_type_id,name,variance,hp,pp,mel_dmg,rng_dmg,tec_dmg,crit_rate,crit_dmg,pp_cost_reduction,active_pp_recovery,natural_pp_recovery,dmg_res,affix_success_rate,all_down_res,burn_res,freeze_res,blind_res,shock_res,panic_res,poison_res,battle_power_value,pb_gauge_build,popularity,editors_choice,element_id,icon)
values((select id from augment_type where name='Ice Weakness' limit 1),1,0,0,0,0,1.02,0,0,0,0,0,0,0,0.09,0,0,0,0,0,0,0,6,0,0,0,(select id from element where name='Ice' limit 1),'');
insert into armor(name,rarity,level_req,def,hp,pp,mel_dmg,rng_dmg,tec_dmg,crit_rate,crit_dmg,pp_cost_reduction,active_pp_recovery,natural_pp_recovery,dmg_res,all_down_res,burn_res,freeze_res,blind_res,shock_res,panic_res,poison_res,battle_power_value,slot,icon,popularity,editors_choice)
values('Primm Armor',1,1,8,10,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,'/icons/20M6Z7t.png',0,0);
@ -268,15 +282,15 @@ insert into class_skill(name,class_id,icon,description)
values('Assault Charge Advent',(SELECT id from class WHERE name='Gunner' limit 1),'','This is ');
insert into class_skill_data(name,class_skill_id,dependency,level,effect,duration,cooldown,damage_taken,pa_potency,conditional_buff,pp_recovery,property,all_damage_buff,active_pp_recovery,status_ailment_accum,status_ailment_duration,pp_consumption,max_hp_decrease,natural_pp_recovery,added_pp,pb_gauge_fortification)
values('Hunter Physique Lv.1',(SELECT id from class_skill WHERE name='Hunter Physique' limit 1),'',1,'Effect Name',20,15,0.7,1,false,0.5,'',0,0,0,0,0,0,0,0,0);
values('Hunter Physique Lv.1',(SELECT id from class_skill WHERE name='Hunter Physique' limit 1),'',1,'Effect Name',20,15,'0.7','1',false,'0.5','','0','0','0','0','0','0','0',0,'0');
insert into class_skill_data(name,class_skill_id,dependency,level,effect,duration,cooldown,damage_taken,pa_potency,conditional_buff,pp_recovery,property,all_damage_buff,active_pp_recovery,status_ailment_accum,status_ailment_duration,pp_consumption,max_hp_decrease,natural_pp_recovery,added_pp,pb_gauge_fortification)
values('War Cry Lv.1',(SELECT id from class_skill WHERE name='War Cry' limit 1),'',1,'Effect Name',14,10,0.5,1.1,false,0.8,'',0,0,0,0.6,0,0,0,0,0);
values('War Cry Lv.1',(SELECT id from class_skill WHERE name='War Cry' limit 1),'',1,'Effect Name',14,10,0.5,'1.1','0.8',false,'0.6','','0','0','0','0','0','0','0',0,'0');
insert into class_skill_data(name,class_skill_id,dependency,level,effect,duration,cooldown,damage_taken,pa_potency,conditional_buff,pp_recovery,property,all_damage_buff,active_pp_recovery,status_ailment_accum,status_ailment_duration,pp_consumption,max_hp_decrease,natural_pp_recovery,added_pp,pb_gauge_fortification)
values('War Cry Lv.2',(SELECT id from class_skill WHERE name='War Cry' limit 1),'',2,'Effect Name',11,11,0.8,1.0,false,0.7,'',0,0,0,0.9,0,0,0,0,0);
values('War Cry Lv.2',(SELECT id from class_skill WHERE name='War Cry' limit 1),'',2,'Effect Name',11,11,'0.8','1',false,'0.5','','0','0','0','0','0','0','0',0,'0');
insert into class_skill_data(name,class_skill_id,dependency,level,effect,duration,cooldown,damage_taken,pa_potency,conditional_buff,pp_recovery,property,all_damage_buff,active_pp_recovery,status_ailment_accum,status_ailment_duration,pp_consumption,max_hp_decrease,natural_pp_recovery,added_pp,pb_gauge_fortification)
values('Assault Charge Advent',(SELECT id from class_skill WHERE name='Assault Charge Advent' limit 1),'',1,'Effect Name',30,24,1.0,1.1,false,0.8,'',0,0,0,0,0,0,0.6,0,0);
values('Assault Charge Advent',(SELECT id from class_skill WHERE name='Assault Charge Advent' limit 1),'',1,'Effect Name',30,24,'1.8','1',false,'0.5','','0','0','0','0','0','0','0',0,'1.6');
insert into skill_tree_data(class_id,data,skill_data,line_color,line_width,gridsizex,gridsizey,gridpaddingx,gridpaddingy,halflineheight)
values((select id from class where name='Hunter'),'□ □ ,└□─┘□□, │ ││, │ □│, □─□┼□, □ ','','#000000',3,80,60,10,10,60);
insert into site_data(field,data) values('UNDER_CONSTRUCTION_TEXT','NGSplanner.com is currently under construction! Please check back after Sig yells at me enough to help finish it.');
insert into site_data(name,data) values('UNDER_CONSTRUCTION_TEXT','NGSplanner.com is currently under construction! Please check back after Sig yells at me enough to help finish it.');

@ -0,0 +1,31 @@
/*9 Aug Database Patch*/
alter table potential add column description text;
alter table weapon_existence_data add column icon text;
alter table weapon_type add column shorthand text;
alter table weapon_existence_data add column special_name text;
alter table potential drop column description;
alter table potential_data add column description text;
alter table photon_art add column icon text;
alter table users add column recovery_hash text;
alter table armor rename column pb_gauge_build to slot;
alter table armor add column battle_power_value text;
CREATE TABLE "skill_tree_data"("id" SERIAL UNIQUE PRIMARY KEY,"class_id" int,"data" text,"skill_data" text,"line_color" text,"line_width" int,"gridsizex" int,"gridsizey" int,"gridpaddingx" int,"gridpaddingy" int);
ALTER TABLE "skill_tree_data" ADD FOREIGN KEY ("class_id") REFERENCES "class" ("id");
alter table skill_tree_data add column halflineheight int;
CREATE TABLE "site_data" ("id" SERIAL UNIQUE PRIMARY KEY,"field" text,"data" text);
alter table class_skill_data alter column damage_taken set data type text;
alter table class_skill_data alter column pa_potency set data type text;
alter table class_skill_data alter column conditional_buff set data type text;
alter table class_skill_data alter column pp_recovery set data type text;
alter table class_skill_data alter column property set data type text;
alter table class_skill_data alter column all_damage_buff set data type text;
alter table class_skill_data alter column active_pp_recovery set data type text;
alter table class_skill_data alter column status_ailment_accum set data type text;
alter table class_skill_data alter column status_ailment_duration set data type text;
alter table class_skill_data alter column pp_consumption set data type text;
alter table class_skill_data alter column max_hp_decrease set data type text;
alter table class_skill_data alter column natural_pp_recovery set data type text;
alter table class_skill_data alter column pb_gauge_fortification set data type text;
alter table site_data rename column field to name;
alter table food add column description text;
alter table food add column icon text;

@ -26,8 +26,7 @@ let allowCrossDomain = function(req, res, next) {
app.use(allowCrossDomain);
app.listen(PORT, () => console.log(`Listening on ${ PORT }`));
var authenticated = true;
const db4=db;
const PREFIX=""
@ -130,14 +129,14 @@ const ENDPOINTDATA=[
},
{
endpoint:"augment",
requiredfields:["augment_type_id","name"],
optionalfields:["variance","hp","pp","mel_dmg","rng_dmg","tec_dmg","crit_rate","crit_dmg","pp_cost_reduction","active_pp_recovery","natural_pp_recovery","dmg_res","affix_success_rate","all_down_res","burn_res","freeze_res","blind_res","shock_res","panic_res","poison_res","battle_power_value","pb_gauge_build","popularity","editors_choice"],
requiredfields:["augment_type_id","name","element_id"],
optionalfields:["variance","hp","pp","mel_dmg","rng_dmg","tec_dmg","crit_rate","crit_dmg","pp_cost_reduction","active_pp_recovery","natural_pp_recovery","dmg_res","affix_success_rate","all_down_res","burn_res","freeze_res","blind_res","shock_res","panic_res","poison_res","battle_power_value","pb_gauge_build","popularity","editors_choice","icon"],
excludedfields:[] //Fields to not output in GET.
},
{
endpoint:"augment_type",
requiredfields:["name"],
optionalfields:["icon"],
optionalfields:[],
excludedfields:[] //Fields to not output in GET.
},
{
@ -184,7 +183,13 @@ const ENDPOINTDATA=[
},
{
endpoint:"site_data",
requiredfields:["field","data"],
requiredfields:["name","data"],
optionalfields:[],
excludedfields:[] //Fields to not output in GET.
},
{
endpoint:"element",
requiredfields:["name"],
optionalfields:[],
excludedfields:[] //Fields to not output in GET.
}
@ -198,7 +203,7 @@ var lockedTime=new Date().getTime()-LOCKOUTTIME //Starts unlocked
for (var test of ["","/test"]) {
app.post(PREFIX+test+"/passwordcheck",(req,res)=>{
db.query('select * from password where password=$1',[req.body.pass])
db4.query('select * from password where password=$1',[req.body.pass])
.then((data)=>{
if (data.rows.length>0) {
res.status(200).json({verified:true})
@ -211,7 +216,7 @@ for (var test of ["","/test"]) {
})
})
app.get(PREFIX+test+"/databases",(req,res)=>{
db.query('select * from password where password=$1',[req.query.pass])
db4.query('select * from password where password=$1',[req.query.pass])
.then((data)=>{
if (data.rows.length>0) {
return db.query('select * from pg_database where datname like \'ngsplanner%\' order by datname desc limit 100')
@ -229,7 +234,7 @@ for (var test of ["","/test"]) {
app.post(PREFIX+test+"/databases/restorefrombackup",(req,res)=>{
if (req.body.database) {
db.query('select * from password where password=$1',[req.body.pass])
db4.query('select * from password where password=$1',[req.body.pass])
.then((data)=>{
if (data.rows.length>0) {
return db3.query('select * from pg_database where datname=$1',[req.body.database])
@ -270,7 +275,7 @@ for (var test of ["","/test"]) {
}
})
app.post(PREFIX+test+"/databases/testtolive",(req,res)=>{
db.query('select * from password where password=$1',[req.body.pass])
db4.query('select * from password where password=$1',[req.body.pass])
.then((data)=>{
if (data.rows.length>0) {
db.end(()=>{})
@ -310,7 +315,7 @@ for (var test of ["","/test"]) {
})
app.post(PREFIX+test+"/databases/livetotest",(req,res)=>{
db.query('select * from password where password=$1',[req.body.pass])
db4.query('select * from password where password=$1',[req.body.pass])
.then((data)=>{
if (data.rows.length>0) {
db.end(()=>{})
@ -350,7 +355,7 @@ for (var test of ["","/test"]) {
app.post(PREFIX+test+"/databases/backup",(req,res)=>{
var date = new Date()
db.query('select * from password where password=$1',[req.body.pass])
db4.query('select * from password where password=$1',[req.body.pass])
.then((data)=>{
if (data.rows.length>0) {
db.end(()=>{})
@ -381,7 +386,7 @@ for (var test of ["","/test"]) {
function CreateDynamicEndpoints() {
ENDPOINTDATA.forEach((endpoint)=>{
app.get(PREFIX+"/"+endpoint.endpoint,(req,res)=>{
db.query('select * from password where password=$1',[req.query.pass])
db4.query('select * from password where password=$1',[req.query.pass])
.then((data)=>{
if (data.rows.length>0) {
if (endpoint.requiredfields.includes("name")) {
@ -408,7 +413,7 @@ function CreateDynamicEndpoints() {
})
app.post(PREFIX+"/"+endpoint.endpoint,async(req,res)=>{
db.query('select * from password where password=$1',[req.body.pass])
db4.query('select * from password where password=$1',[req.body.pass])
.then(async(data)=>{
if (data.rows.length>0) {
var allExist=true
@ -430,7 +435,7 @@ function CreateDynamicEndpoints() {
await db.query('update '+endpoint.endpoint+' set '+all_filled_fields.map((field,i)=>{
if (!field.includes("_id")) {return field+"=$"+(i+1)}else{
if (Number.isNaN(Number(req.body[field]))) {return field+"=(select id from "+field.replace("_id","")+" where name=$"+(i+1)+")"} else {return field+"=$"+(i+1)}
}}).join(",")+' where name=$'+(all_filled_fields.length+1)+' returning *',[...all_filled_fields.map((field)=>req.body[field]),req.body["name"]])
}}).join(",")+' where name=$'+(all_filled_fields.length+1)+' returning *',[...all_filled_fields.map((field)=>typeof req.body[field]==='string'?req.body[field].trim():req.body[field]),req.body["name"]])
.then((data)=>{
if (data.rows.length===0) {
requiresInsert=true
@ -447,7 +452,7 @@ function CreateDynamicEndpoints() {
db.query('insert into '+endpoint.endpoint+"("+all_filled_fields.join(',')+") values("+all_filled_fields.map((field,i)=>{
if (!field.includes("_id")) {return "$"+(i+1)}else{
if (Number.isNaN(Number(req.body[field]))) {return "(select id from "+field.replace("_id","")+" where name=$"+(i+1)+")"} else {return "$"+(i+1)}
}}).join(",")+") returning *",all_filled_fields.map((field)=>req.body[field]))
}}).join(",")+") returning *",all_filled_fields.map((field)=>typeof req.body[field]==='string'?req.body[field].trim():req.body[field]))
.then((data)=>{
res.status(200).json(data.rows)
})
@ -455,7 +460,7 @@ function CreateDynamicEndpoints() {
res.status(500).send(err.message)
})
}app.post(PREFIX+"/"+endpoint.endpoint,async(req,res)=>{
db.query('select * from password where password=$1',[req.body.pass])
db4.query('select * from password where password=$1',[req.body.pass])
.then(async(data)=>{
if (data.rows.length>0) {
var allExist=true
@ -477,7 +482,7 @@ function CreateDynamicEndpoints() {
await db.query('update '+endpoint.endpoint+' set '+all_filled_fields.map((field,i)=>{
if (!field.includes("_id")) {return field+"=$"+(i+1)}else{
if (Number.isNaN(Number(req.body[field]))) {return field+"=(select id from "+field.replace("_id","")+" where name=$"+(i+1)+")"} else {return field+"=$"+(i+1)}
}}).join(",")+' where name=$'+(all_filled_fields.length+1)+' returning *',[...all_filled_fields.map((field)=>req.body[field]),req.body["name"]])
}}).join(",")+' where name=$'+(all_filled_fields.length+1)+' returning *',[...all_filled_fields.map((field)=>typeof req.body[field]==='string'?req.body[field].trim():req.body[field]),req.body["name"]])
.then((data)=>{
if (data.rows.length===0) {
requiresInsert=true
@ -494,7 +499,7 @@ function CreateDynamicEndpoints() {
db.query('insert into '+endpoint.endpoint+"("+all_filled_fields.join(',')+") values("+all_filled_fields.map((field,i)=>{
if (!field.includes("_id")) {return "$"+(i+1)}else{
if (Number.isNaN(Number(req.body[field]))) {return "(select id from "+field.replace("_id","")+" where name=$"+(i+1)+")"} else {return "$"+(i+1)}
}}).join(",")+") returning *",all_filled_fields.map((field)=>req.body[field]))
}}).join(",")+") returning *",all_filled_fields.map((field)=>typeof req.body[field]==='string'?req.body[field].trim():req.body[field]))
.then((data)=>{
res.status(200).json(data.rows)
})
@ -515,14 +520,14 @@ function CreateDynamicEndpoints() {
app.patch(PREFIX+"/"+endpoint.endpoint,(req,res)=>{
if (req.body.id) {
db.query('select * from password where password=$1',[req.body.pass])
db4.query('select * from password where password=$1',[req.body.pass])
.then((data)=>{
if (data.rows.length>0) {
var combinedfields = [...endpoint.requiredfields,...endpoint.optionalfields,...endpoint.excludedfields]
//console.log(combinedfields)
var all_filled_fields=combinedfields.filter((field)=>(field in req.body))
return db.query('update '+endpoint.endpoint+' set '+all_filled_fields.map((field,i)=>field+"=$"+(i+1)).join(",")+" where id=$"+(all_filled_fields.length+1)+" returning *",[...all_filled_fields.map((field)=>req.body[field]),req.body.id])
return db.query('update '+endpoint.endpoint+' set '+all_filled_fields.map((field,i)=>field+"=$"+(i+1)).join(",")+" where id=$"+(all_filled_fields.length+1)+" returning *",[...all_filled_fields.map((field)=>typeof req.body[field]==='string'?req.body[field].trim():req.body[field]),req.body.id])
} else {
var msg="Could not authenticate!";res.status(500).send(msg);throw msg
}
@ -540,7 +545,7 @@ function CreateDynamicEndpoints() {
app.delete(PREFIX+"/"+endpoint.endpoint,(req,res)=>{
if (req.body.id) {
db.query('select * from password where password=$1',[req.body.pass])
db4.query('select * from password where password=$1',[req.body.pass])
.then((data)=>{
if (data.rows.length>0) {
return db.query('delete from '+endpoint.endpoint+' where id=$1 returning *',[req.body.id])
@ -560,7 +565,7 @@ function CreateDynamicEndpoints() {
})
app.get(PREFIX+"/test/"+endpoint.endpoint,(req,res)=>{
db.query('select * from password where password=$1',[req.query.pass])
db4.query('select * from password where password=$1',[req.query.pass])
.then((data)=>{
if (data.rows.length>0) {
if (endpoint.requiredfields.includes("name")) {
@ -587,7 +592,7 @@ function CreateDynamicEndpoints() {
})
app.post(PREFIX+"/test/"+endpoint.endpoint,async(req,res)=>{
db.query('select * from password where password=$1',[req.body.pass])
db4.query('select * from password where password=$1',[req.body.pass])
.then(async(data)=>{
if (data.rows.length>0) {
var allExist=true
@ -606,7 +611,7 @@ function CreateDynamicEndpoints() {
var all_filled_fields=combinedfields.filter((field)=>(field in req.body))
var requiresInsert=true
if (endpoint.requiredfields.includes("name")) {
await db2.query('update '+endpoint.endpoint+' set '+all_filled_fields.map((field,i)=>field+"=$"+(i+1)).join(",")+' where name=$'+(all_filled_fields.length+1)+' returning *',[...all_filled_fields.map((field)=>req.body[field]),req.body["name"]])
await db2.query('update '+endpoint.endpoint+' set '+all_filled_fields.map((field,i)=>field+"=$"+(i+1)).join(",")+' where name=$'+(all_filled_fields.length+1)+' returning *',[...all_filled_fields.map((field)=>typeof req.body[field]==='string'?req.body[field].trim():req.body[field]),req.body["name"]])
.then((data)=>{
if (data.rows.length===0) {
requiresInsert=true
@ -620,7 +625,7 @@ function CreateDynamicEndpoints() {
})
}
if (requiresInsert) {
db2.query('insert into '+endpoint.endpoint+"("+all_filled_fields.join(',')+") values("+all_filled_fields.map((field,i)=>"$"+(i+1)).join(",")+") returning *",all_filled_fields.map((field)=>req.body[field]))
db2.query('insert into '+endpoint.endpoint+"("+all_filled_fields.join(',')+") values("+all_filled_fields.map((field,i)=>"$"+(i+1)).join(",")+") returning *",all_filled_fields.map((field)=>typeof req.body[field]==='string'?req.body[field].trim():req.body[field]))
.then((data)=>{
res.status(200).json(data.rows)
})
@ -636,14 +641,14 @@ function CreateDynamicEndpoints() {
app.patch(PREFIX+"/test/"+endpoint.endpoint,(req,res)=>{
if (req.body.id) {
db.query('select * from password where password=$1',[req.body.pass])
db4.query('select * from password where password=$1',[req.body.pass])
.then((data)=>{
if (data.rows.length>0) {
var combinedfields = [...endpoint.requiredfields,...endpoint.optionalfields,...endpoint.excludedfields]
//console.log(combinedfields)
var all_filled_fields=combinedfields.filter((field)=>(field in req.body))
return db2.query('update '+endpoint.endpoint+' set '+all_filled_fields.map((field,i)=>field+"=$"+(i+1)).join(",")+" where id=$"+(all_filled_fields.length+1)+" returning *",[...all_filled_fields.map((field)=>req.body[field]),req.body.id])
return db2.query('update '+endpoint.endpoint+' set '+all_filled_fields.map((field,i)=>field+"=$"+(i+1)).join(",")+" where id=$"+(all_filled_fields.length+1)+" returning *",[...all_filled_fields.map((field)=>typeof req.body[field]==='string'?req.body[field].trim():req.body[field]),req.body.id])
} else {
var msg="Could not authenticate!";res.status(500).send(msg);throw msg
}
@ -661,7 +666,7 @@ function CreateDynamicEndpoints() {
app.delete(PREFIX+"/test/"+endpoint.endpoint,(req,res)=>{
if (req.body.id) {
db.query('select * from password where password=$1',[req.body.pass])
db4.query('select * from password where password=$1',[req.body.pass])
.then((data)=>{
if (data.rows.length>0) {
return db2.query('delete from '+endpoint.endpoint+' where id=$1 returning *',[req.body.id])
@ -695,17 +700,19 @@ app.get(PREFIX+'/data',async(req,res)=>{
var finalresult = {}
var promises = []
for (var endpoint of ENDPOINTDATA) {
if (endpoint.requiredfields.includes("name")) {
await db.query('select * from (select distinct on (name) name,* from '+endpoint.endpoint+' order by name,id desc)t order by id asc')
.then((data)=>{
finalresult[endpoint.endpoint]={}
data.rows.forEach((val)=>{finalresult[endpoint.endpoint][val.name]=val})
})
} else {
await db.query('select * from '+endpoint.endpoint+" order by id desc")
.then((data)=>{
finalresult[endpoint.endpoint]=data.rows
})
if (endpoint.endpoint!=="builds"&&endpoint.endpoint!=="users") {
if (endpoint.requiredfields.includes("name")) {
await db.query('select * from (select distinct on (name) name,* from '+endpoint.endpoint+' order by name,id desc)t order by id asc')
.then((data)=>{
finalresult[endpoint.endpoint]={}
data.rows.forEach((val)=>{finalresult[endpoint.endpoint][val.name]=val})
})
} else {
await db.query('select * from '+endpoint.endpoint+" order by id desc")
.then((data)=>{
finalresult[endpoint.endpoint]=data.rows
})
}
}
}
res.status(200).json(finalresult)
@ -715,17 +722,19 @@ app.get(PREFIX+'/test/data',async(req,res)=>{
var finalresult = {}
var promises = []
for (var endpoint of ENDPOINTDATA) {
if (endpoint.requiredfields.includes("name")) {
await db2.query('select distinct on (name) name,* from '+endpoint.endpoint+' order by name,id desc')
.then((data)=>{
finalresult[endpoint.endpoint]={}
data.rows.forEach((val)=>{finalresult[endpoint.endpoint][val.name]=val})
})
} else {
await db2.query('select * from '+endpoint.endpoint+" order by id desc")
.then((data)=>{
finalresult[endpoint.endpoint]=data.rows
})
if (endpoint.endpoint!=="builds"&&endpoint.endpoint!=="users") {
if (endpoint.requiredfields.includes("name")) {
await db2.query('select distinct on (name) name,* from '+endpoint.endpoint+' order by name,id desc')
.then((data)=>{
finalresult[endpoint.endpoint]={}
data.rows.forEach((val)=>{finalresult[endpoint.endpoint][val.name]=val})
})
} else {
await db2.query('select * from '+endpoint.endpoint+" order by id desc")
.then((data)=>{
finalresult[endpoint.endpoint]=data.rows
})
}
}
}
res.status(200).json(finalresult)
@ -735,11 +744,13 @@ app.get(PREFIX+'/dataid',async(req,res)=>{
var finalresult = {}
var promises = []
for (var endpoint of ENDPOINTDATA) {
await db.query('select * from '+endpoint.endpoint+' order by id asc')
.then((data)=>{
finalresult[endpoint.endpoint]={}
data.rows.forEach((val)=>{finalresult[endpoint.endpoint][val.id]=val})
})
if (endpoint.endpoint!=="builds"&&endpoint.endpoint!=="users") {
await db.query('select * from '+endpoint.endpoint+' order by id asc')
.then((data)=>{
finalresult[endpoint.endpoint]={}
data.rows.forEach((val)=>{finalresult[endpoint.endpoint][val.id]=val})
})
}
}
res.status(200).json(finalresult)
})
@ -748,11 +759,13 @@ app.get(PREFIX+'/test/dataid',async(req,res)=>{
var finalresult = {}
var promises = []
for (var endpoint of ENDPOINTDATA) {
await db2.query('select * from '+endpoint.endpoint+' order by id asc')
.then((data)=>{
finalresult[endpoint.endpoint]={}
data.rows.forEach((val)=>{finalresult[endpoint.endpoint][val.id]=val})
})
if (endpoint.endpoint!=="builds"&&endpoint.endpoint!=="users") {
await db2.query('select * from '+endpoint.endpoint+' order by id asc')
.then((data)=>{
finalresult[endpoint.endpoint]={}
data.rows.forEach((val)=>{finalresult[endpoint.endpoint][val.id]=val})
})
}
}
res.status(200).json(finalresult)
})
@ -773,7 +786,7 @@ app.post(PREFIX+"/validUser",(req,res)=>{
})
app.post(PREFIX+"/saveskilltree",(req,res)=>{
db.query('select * from password where password=$1',[req.body.pass])
db4.query('select * from password where password=$1',[req.body.pass])
.then((data)=>{
if (data.rows.length>0) {
return db.query('select * from skill_tree_data where class_id=$1 limit 1',[req.body.class_id])
@ -799,7 +812,7 @@ app.post(PREFIX+"/saveskilltree",(req,res)=>{
})
app.post(PREFIX+"/test/saveskilltree",(req,res)=>{
db.query('select * from password where password=$1',[req.body.pass])
db4.query('select * from password where password=$1',[req.body.pass])
.then((data)=>{
if (data.rows.length>0) {
return db2.query('select * from skill_tree_data where class_id=$1 limit 1',[req.body.class_id])
@ -824,6 +837,71 @@ app.post(PREFIX+"/test/saveskilltree",(req,res)=>{
})
})
function submitBuild(req,res,db,send) {
if (req.body.id) {
db.query('select users.username from builds join users on users_id=users.id where builds.id=$1',[req.body.id])
.then((data)=>{
console.log(data.rows)
if (data.rows.length>0&&data.rows[0].username===req.body.username) {
return db.query('update builds set creator=$1,build_name=$2,class1=(SELECT id from class WHERE name=$3 limit 1),class2=(SELECT id from class WHERE name=$4 limit 1),last_modified=$5,data=$6 where id=$7 returning id',[req.body.creator,req.body.build_name,req.body.class1,req.body.class2,new Date(),req.body.data,req.body.id])
.then((data)=>{
if (send) {
res.status(200).send(data.rows[0])
}
})
.catch((err)=>{
console.log(err.message)
if (send) {
res.status(500).send(err.message)
}
})
} else {
return db.query('insert into builds(users_id,creator,build_name,class1,class2,created_on,last_modified,likes,data,editors_choice) values((SELECT id from users WHERE username=$1 limit 1),$2,$3,(SELECT id from class WHERE name=$4 limit 1),(SELECT id from class WHERE name=$5 limit 1),$6,$7,$8,$9,$10) returning id',[req.body.username,req.body.creator,req.body.build_name,req.body.class1,req.body.class2,new Date(),new Date(),0,req.body.data,0])
.then((data)=>{
if (send) {
res.status(200).send(data.rows[0])
}
})
.catch((err)=>{
console.log(err.message)
if (send) {
res.status(500).send(err.message)
}
})
}
})
.catch((err)=>{
console.log(err.message)
if (send) {
res.status(500).send(err.message)
}
})
} else {
db.query('insert into builds(users_id,creator,build_name,class1,class2,created_on,last_modified,likes,data,editors_choice) values((SELECT id from users WHERE username=$1 limit 1),$2,$3,(SELECT id from class WHERE name=$4 limit 1),(SELECT id from class WHERE name=$5 limit 1),$6,$7,$8,$9,$10) returning id',[req.body.username,req.body.creator,req.body.build_name,req.body.class1,req.body.class2,new Date(),new Date(),0,req.body.data,0])
.then((data)=>{
if (send) {
res.status(200).send(data.rows[0])
}
})
.catch((err)=>{
console.log(err.message)
if (send) {
res.status(500).send(err.message)
}
})
}
}
app.post(PREFIX+"/submitBuild",(req,res)=>{
submitBuild(req,res,db,true)
submitBuild(req,res,db2,false)
})
app.post(PREFIX+"/test/submitBuild",(req,res)=>{
submitBuild(req,res,db,true)
submitBuild(req,res,db2,false)
})
//Generates our table schema:
ENDPOINTDATA.forEach((endpoint)=>{
console.log(endpoint.endpoint+":\n\t"+endpoint.requiredfields.join('\t')+(endpoint.optionalfields.length>0?"\t":"")+endpoint.optionalfields.join("\t"))

Loading…
Cancel
Save