This commit is contained in:
Jānis 2024-09-03 20:21:09 +03:00
parent 58b1cfc30f
commit 3403d496b4
10 changed files with 29 additions and 170 deletions

View File

@ -15,7 +15,7 @@ import { statsRouter } from "@/src/routes/stats";
import { webuiRouter } from "@/src/routes/webui"; import { webuiRouter } from "@/src/routes/webui";
import { connectDatabase } from "@/src/services/mongoService"; import { connectDatabase } from "@/src/services/mongoService";
import { registerLogFileCreationListener } from "@/src/utils/logger"; import { registerLogFileCreationListener } from "@/src/utils/logger";
import * as zlib from 'zlib'; import * as zlib from "zlib";
void registerLogFileCreationListener(); void registerLogFileCreationListener();
void connectDatabase(); void connectDatabase();
@ -23,17 +23,17 @@ void connectDatabase();
const app = express(); const app = express();
app.use(function (req, _res, next) { app.use(function (req, _res, next) {
var buffer: Buffer[] = [] const buffer: Buffer[] = [];
req.on('data', function (chunk: Buffer) { req.on("data", function (chunk: Buffer) {
if (chunk !== undefined && chunk.length > 2 && chunk[0] == 0x1f && chunk[1] == 0x8b) { if (chunk !== undefined && chunk.length > 2 && chunk[0] == 0x1f && chunk[1] == 0x8b) {
buffer.push(Buffer.from(chunk)); buffer.push(Buffer.from(chunk));
} }
}); });
req.on('end', function () { req.on("end", function () {
zlib.gunzip(Buffer.concat(buffer), function (_err, dezipped) { zlib.gunzip(Buffer.concat(buffer), function (_err, dezipped) {
if (typeof dezipped != 'undefined') { if (typeof dezipped != "undefined") {
req.body = dezipped.toString('utf-8'); req.body = dezipped.toString("utf-8");
} }
next(); next();

View File

@ -1,10 +1,6 @@
import { RequestHandler } from "express"; import { RequestHandler } from "express";
import { Inventory } from "@/src/models/inventoryModels/inventoryModel";
import { Guild } from "@/src/models/guildModel";
import { getAccountIdForRequest } from "@/src/services/loginService";
import { toOid } from "@/src/helpers/inventoryHelpers";
const getGuildController: RequestHandler = async (_, res) => { const getGuildController: RequestHandler = (_, res) => {
res.json({}); res.json({});
}; };

View File

@ -3,13 +3,8 @@ import { getAccountIdForRequest } from "@/src/services/loginService";
import { toInventoryResponse } from "@/src/helpers/inventoryHelpers"; import { toInventoryResponse } from "@/src/helpers/inventoryHelpers";
import { Inventory } from "@/src/models/inventoryModels/inventoryModel"; import { Inventory } from "@/src/models/inventoryModels/inventoryModel";
import { config } from "@/src/services/configService"; import { config } from "@/src/services/configService";
import allDialogue from "@/static/fixed_responses/allDialogue.json"; import { IInventoryDatabase } from "@/src/types/inventoryTypes/inventoryTypes";
import allMissions from "@/static/fixed_responses/allMissions.json"; import { ExportCustoms, ExportFlavour } from "warframe-public-export-plus";
import { ILoadoutDatabase } from "@/src/types/saveLoadoutTypes";
import { IInventoryDatabase, IShipInventory, equipmentKeys } from "@/src/types/inventoryTypes/inventoryTypes";
import { IPolarity, ArtifactPolarity } from "@/src/types/inventoryTypes/commonInventoryTypes";
import { ExportCustoms, ExportFlavour, ExportKeys, ExportResources } from "warframe-public-export-plus";
import { IFlavourItem } from "@/src/types/inventoryTypes/inventoryTypes";
// eslint-disable-next-line @typescript-eslint/no-misused-promises // eslint-disable-next-line @typescript-eslint/no-misused-promises
const inventoryController: RequestHandler = async (request, response) => { const inventoryController: RequestHandler = async (request, response) => {
@ -90,11 +85,12 @@ const inventoryController: RequestHandler = async (request, response) => {
response.json(inventoryResponse); response.json(inventoryResponse);
}; };
/*
const addString = (arr: string[], str: string): void => { const addString = (arr: string[], str: string): void => {
if (!arr.find(x => x == str)) { if (!arr.find(x => x == str)) {
arr.push(str); arr.push(str);
} }
}; };*/
const getExpRequiredForMr = (rank: number): number => { const getExpRequiredForMr = (rank: number): number => {
if (rank <= 30) { if (rank <= 30) {

View File

@ -25,7 +25,7 @@ const loginController: RequestHandler = async (request, response) => {
email: loginRequest.email, email: loginRequest.email,
password: loginRequest.password, password: loginRequest.password,
DisplayName: loginRequest.email.substring(0, loginRequest.email.indexOf("@")), DisplayName: loginRequest.email.substring(0, loginRequest.email.indexOf("@")),
Nonce: nonce, Nonce: nonce
}); });
logger.debug("created new account"); logger.debug("created new account");
// eslint-disable-next-line @typescript-eslint/no-unused-vars // eslint-disable-next-line @typescript-eslint/no-unused-vars

View File

@ -8,8 +8,7 @@ import { logger } from "@/src/utils/logger";
export const tauntHistoryController: RequestHandler = async (req, res) => { export const tauntHistoryController: RequestHandler = async (req, res) => {
const accountId = await getAccountIdForRequest(req); const accountId = await getAccountIdForRequest(req);
const inventory = await getInventory(accountId); const inventory = await getInventory(accountId);
if(req.body !== undefined) if (req.body !== undefined) {
{
const clientTaunt = JSON.parse(String(req.body)) as ITaunt; const clientTaunt = JSON.parse(String(req.body)) as ITaunt;
logger.debug(`updating taunt ${clientTaunt.node} to state ${clientTaunt.state}`); logger.debug(`updating taunt ${clientTaunt.node} to state ${clientTaunt.state}`);
inventory.TauntHistory ??= []; inventory.TauntHistory ??= [];
@ -21,8 +20,7 @@ export const tauntHistoryController: RequestHandler = async (req, res) => {
} }
await inventory.save(); await inventory.save();
res.end(); res.end();
}else } else {
{
res.json({}); res.json({});
} }
}; };

View File

@ -1,25 +1,20 @@
import { getAccountIdForRequest } from "@/src/services/loginService"; import { getAccountIdForRequest } from "@/src/services/loginService";
import { getJSONfromString } from "@/src/helpers/stringHelpers";
import { startRecipe } from "@/src/services/recipeService";
import { logger } from "@/src/utils/logger";
import { RequestHandler } from "express"; import { RequestHandler } from "express";
import { getInventory } from "@/src/services/inventoryService"; import { getInventory } from "@/src/services/inventoryService";
// eslint-disable-next-line @typescript-eslint/no-misused-promises // eslint-disable-next-line @typescript-eslint/no-misused-promises
export const updateInventoryController: RequestHandler = async (req, res) => { export const updateInventoryController: RequestHandler = async (req, res) => {
const accountId = await getAccountIdForRequest(req); const accountId = await getAccountIdForRequest(req);
const body = JSON.parse(req.body); const body: any = JSON.parse(req.body as string);
const inventory = await getInventory(accountId); const inventory = await getInventory(accountId);
inventory.Missions.push({Tag: body.Missions.Tag, Completes: body.Missions.Completes, BestRating: 0.2 }) inventory.Missions.push({ Tag: body.Missions.Tag, Completes: body.Missions.Completes, BestRating: 0.2 });
await inventory.save(); await inventory.save();
console.log(body); console.log(body);
res.json({}) res.json({});
}; };
/* /*
{ {
"LongGuns" : [ "LongGuns" : [

View File

@ -1,5 +1,5 @@
import { ILoginRequest } from "@/src/types/loginTypes"; import { ILoginRequest } from "@/src/types/loginTypes";
import { parseEmail, parseNumber, parseString } from "./general"; import { parseEmail, parseString } from "./general";
const toLoginRequest = (loginRequest: unknown): ILoginRequest => { const toLoginRequest = (loginRequest: unknown): ILoginRequest => {
if (!loginRequest || typeof loginRequest !== "object") { if (!loginRequest || typeof loginRequest !== "object") {
@ -7,10 +7,7 @@ const toLoginRequest = (loginRequest: unknown): ILoginRequest => {
} }
// TODO: function that checks whether every field of interface is in object // TODO: function that checks whether every field of interface is in object
if ( if ("email" in loginRequest && "password" in loginRequest) {
"email" in loginRequest &&
"password" in loginRequest
) {
return { return {
email: parseEmail(loginRequest.email), email: parseEmail(loginRequest.email),
password: parseString(loginRequest.password) password: parseString(loginRequest.password)

View File

@ -13,30 +13,18 @@ import {
IPendingRecipe as IPendingRecipeDatabase, IPendingRecipe as IPendingRecipeDatabase,
IPendingRecipeResponse, IPendingRecipeResponse,
ITypeCount, ITypeCount,
IFocusXP,
IFocusUpgrades,
ITypeXPItem, ITypeXPItem,
IChallengeProgress, IChallengeProgress,
IStepSequencer, IStepSequencer,
IAffiliation,
INotePacks, INotePacks,
ICompletedJobChain,
ISeasonChallenge,
IPlayerSkills, IPlayerSkills,
ISettings, ISettings,
IInfestedFoundry,
IConsumedSuit,
IQuestProgress, IQuestProgress,
IQuestKeyDatabase, IQuestKeyDatabase,
IQuestKeyResponse, IQuestKeyResponse,
IFusionTreasure,
ISpectreLoadout,
IWeaponSkinDatabase, IWeaponSkinDatabase,
ITaunt,
IPeriodicMissionCompletionDatabase, IPeriodicMissionCompletionDatabase,
IPeriodicMissionCompletionResponse, IPeriodicMissionCompletionResponse
ILoreFragmentScan,
IEvolutionProgress
} from "../../types/inventoryTypes/inventoryTypes"; } from "../../types/inventoryTypes/inventoryTypes";
import { IOid } from "../../types/commonTypes"; import { IOid } from "../../types/commonTypes";
import { import {
@ -53,26 +41,6 @@ import { toMongoDate, toOid } from "@/src/helpers/inventoryHelpers";
const typeCountSchema = new Schema<ITypeCount>({ ItemType: String, ItemCount: Number }, { _id: false }); const typeCountSchema = new Schema<ITypeCount>({ ItemType: String, ItemCount: Number }, { _id: false });
const focusXPSchema = new Schema<IFocusXP>(
{
AP_POWER: Number,
AP_TACTIC: Number,
AP_DEFENSE: Number,
AP_ATTACK: Number,
AP_WARD: Number
},
{ _id: false }
);
const focusUpgradesSchema = new Schema<IFocusUpgrades>(
{
ItemType: String,
Level: Number,
IsUniversal: Boolean
},
{ _id: false }
);
const pendingRecipeSchema = new Schema<IPendingRecipeDatabase>( const pendingRecipeSchema = new Schema<IPendingRecipeDatabase>(
{ {
ItemType: String, ItemType: String,
@ -394,34 +362,6 @@ StepSequencersSchema.set("toJSON", {
} }
}); });
const affiliationsSchema = new Schema<IAffiliation>(
{
Initiated: Boolean,
Standing: Number,
Title: Number,
FreeFavorsEarned: { type: [Number], default: undefined },
FreeFavorsUsed: { type: [Number], default: undefined },
Tag: String
},
{ _id: false }
);
const completedJobChainsSchema = new Schema<ICompletedJobChain>(
{
LocationTag: String,
Jobs: [String]
},
{ _id: false }
);
const seasonChallengeHistorySchema = new Schema<ISeasonChallenge>(
{
challenge: String,
id: String
},
{ _id: false }
);
//TODO: check whether this is complete //TODO: check whether this is complete
const playerSkillsSchema = new Schema<IPlayerSkills>( const playerSkillsSchema = new Schema<IPlayerSkills>(
{ {
@ -449,25 +389,6 @@ const settingsSchema = new Schema<ISettings>({
TradingRulesConfirmed: Boolean TradingRulesConfirmed: Boolean
}); });
const consumedSchuitsSchema = new Schema<IConsumedSuit>({
s: String,
c: colorSchema
});
const infestedFoundrySchema = new Schema<IInfestedFoundry>(
{
Name: String,
Resources: { type: [typeCountSchema], default: undefined },
Slots: Number,
XP: Number,
ConsumedSuits: { type: [consumedSchuitsSchema], default: undefined },
InvigorationIndex: Number,
InvigorationSuitOfferings: { type: [String], default: undefined },
InvigorationsApplied: Number
},
{ _id: false }
);
const questProgressSchema = new Schema<IQuestProgress>({ const questProgressSchema = new Schema<IQuestProgress>({
c: Number, c: Number,
i: Boolean, i: Boolean,
@ -499,21 +420,6 @@ questKeysSchema.set("toJSON", {
} }
}); });
const fusionTreasuresSchema = new Schema<IFusionTreasure>().add(typeCountSchema).add({ Sockets: Number });
const spectreLoadoutsSchema = new Schema<ISpectreLoadout>(
{
LongGuns: String,
Melee: String,
Pistols: String,
PistolsFeatures: Number,
PistolsModularParts: [String],
Suits: String,
ItemType: String
},
{ _id: false }
);
const weaponSkinsSchema = new Schema<IWeaponSkinDatabase>( const weaponSkinsSchema = new Schema<IWeaponSkinDatabase>(
{ {
ItemType: String ItemType: String
@ -533,14 +439,6 @@ weaponSkinsSchema.set("toJSON", {
} }
}); });
const tauntSchema = new Schema<ITaunt>(
{
node: String,
state: String
},
{ _id: false }
);
const periodicMissionCompletionsSchema = new Schema<IPeriodicMissionCompletionDatabase>( const periodicMissionCompletionsSchema = new Schema<IPeriodicMissionCompletionDatabase>(
{ {
date: Date, date: Date,
@ -560,24 +458,6 @@ periodicMissionCompletionsSchema.set("toJSON", {
} }
}); });
const loreFragmentScansSchema = new Schema<ILoreFragmentScan>(
{
Progress: Number,
Region: String,
ItemType: String
},
{ _id: false }
);
const evolutionProgressSchema = new Schema<IEvolutionProgress>(
{
Progress: Number,
Rank: Number,
ItemType: String
},
{ _id: false }
);
const inventorySchema = new Schema<IInventoryDatabase, InventoryDocumentProps>( const inventorySchema = new Schema<IInventoryDatabase, InventoryDocumentProps>(
{ {
accountOwnerId: Schema.Types.ObjectId, accountOwnerId: Schema.Types.ObjectId,
@ -656,7 +536,6 @@ const inventorySchema = new Schema<IInventoryDatabase, InventoryDocumentProps>(
//Id CompletedAlerts //Id CompletedAlerts
CompletedAlerts: [String], CompletedAlerts: [String],
//Resource,Credit,Affinity etc or Bless any boosters //Resource,Credit,Affinity etc or Bless any boosters
Boosters: [boosterSchema], Boosters: [boosterSchema],
@ -687,7 +566,6 @@ const inventorySchema = new Schema<IInventoryDatabase, InventoryDocumentProps>(
//TradeBannedUntil data //TradeBannedUntil data
TradeBannedUntil: Schema.Types.Mixed, TradeBannedUntil: Schema.Types.Mixed,
//Unknown and system //Unknown and system
Mailbox: MailboxSchema, Mailbox: MailboxSchema,
HandlerPoints: Number, HandlerPoints: Number,

View File

@ -101,16 +101,16 @@ apiRouter.get("/setSupportedSyndicate.php", setSupportedSyndicateController);
apiRouter.get("/surveys.php", surveysController); apiRouter.get("/surveys.php", surveysController);
apiRouter.get("/updateSession.php", updateSessionGetController); apiRouter.get("/updateSession.php", updateSessionGetController);
apiRouter.get('/getMessages.php', (_, response) => { apiRouter.get("/getMessages.php", (_, response) => {
response.json({}); response.json({});
}) });
apiRouter.get('/trainingResult.php', (_, response) => { apiRouter.get("/trainingResult.php", (_, response) => {
response.status(200); response.status(200);
}) });
apiRouter.get('/giveStartingGear.php', (_, response) => { apiRouter.get("/giveStartingGear.php", (_, response) => {
response.status(200); response.status(200);
}) });
apiRouter.get('/worldState.php', worldStateController); apiRouter.get("/worldState.php", worldStateController);
// post // post
apiRouter.post("/addFriendImage.php", addFriendImageController); apiRouter.post("/addFriendImage.php", addFriendImageController);
apiRouter.post("/artifacts.php", artifactsController); apiRouter.post("/artifacts.php", artifactsController);

View File

@ -12,7 +12,6 @@ cacheRouter.get("/B.Cache.Windows_en.bin*", (_req, res) => {
res.sendFile("static/data/B.Cache.Windows_en_33.0.10.bin", { root: "./" }); res.sendFile("static/data/B.Cache.Windows_en_33.0.10.bin", { root: "./" });
}); });
cacheRouter.get("/H.Cache.bin!03_---------------------w", (_req, res) => { cacheRouter.get("/H.Cache.bin!03_---------------------w", (_req, res) => {
res.sendFile(`static/data/H.Cache.bin`, { root: "./" }); res.sendFile(`static/data/H.Cache.bin`, { root: "./" });
}); });