forked from OpenWF/SpaceNinjaServer
		
	fix lint
This commit is contained in:
		
							parent
							
								
									58b1cfc30f
								
							
						
					
					
						commit
						3403d496b4
					
				
							
								
								
									
										12
									
								
								src/app.ts
									
									
									
									
									
								
							
							
						
						
									
										12
									
								
								src/app.ts
									
									
									
									
									
								
							@ -15,7 +15,7 @@ import { statsRouter } from "@/src/routes/stats";
 | 
			
		||||
import { webuiRouter } from "@/src/routes/webui";
 | 
			
		||||
import { connectDatabase } from "@/src/services/mongoService";
 | 
			
		||||
import { registerLogFileCreationListener } from "@/src/utils/logger";
 | 
			
		||||
import * as zlib from 'zlib';
 | 
			
		||||
import * as zlib from "zlib";
 | 
			
		||||
 | 
			
		||||
void registerLogFileCreationListener();
 | 
			
		||||
void connectDatabase();
 | 
			
		||||
@ -23,17 +23,17 @@ void connectDatabase();
 | 
			
		||||
const app = express();
 | 
			
		||||
 | 
			
		||||
app.use(function (req, _res, next) {
 | 
			
		||||
    var buffer: Buffer[] = []
 | 
			
		||||
    req.on('data', function (chunk: Buffer) {
 | 
			
		||||
    const buffer: Buffer[] = [];
 | 
			
		||||
    req.on("data", function (chunk: Buffer) {
 | 
			
		||||
        if (chunk !== undefined && chunk.length > 2 && chunk[0] == 0x1f && chunk[1] == 0x8b) {
 | 
			
		||||
            buffer.push(Buffer.from(chunk));
 | 
			
		||||
        }
 | 
			
		||||
    });
 | 
			
		||||
 | 
			
		||||
    req.on('end', function () {
 | 
			
		||||
    req.on("end", function () {
 | 
			
		||||
        zlib.gunzip(Buffer.concat(buffer), function (_err, dezipped) {
 | 
			
		||||
            if (typeof dezipped != 'undefined') {
 | 
			
		||||
                req.body = dezipped.toString('utf-8');
 | 
			
		||||
            if (typeof dezipped != "undefined") {
 | 
			
		||||
                req.body = dezipped.toString("utf-8");
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            next();
 | 
			
		||||
 | 
			
		||||
@ -1,10 +1,6 @@
 | 
			
		||||
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({});
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -3,13 +3,8 @@ import { getAccountIdForRequest } from "@/src/services/loginService";
 | 
			
		||||
import { toInventoryResponse } from "@/src/helpers/inventoryHelpers";
 | 
			
		||||
import { Inventory } from "@/src/models/inventoryModels/inventoryModel";
 | 
			
		||||
import { config } from "@/src/services/configService";
 | 
			
		||||
import allDialogue from "@/static/fixed_responses/allDialogue.json";
 | 
			
		||||
import allMissions from "@/static/fixed_responses/allMissions.json";
 | 
			
		||||
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";
 | 
			
		||||
import { IInventoryDatabase } from "@/src/types/inventoryTypes/inventoryTypes";
 | 
			
		||||
import { ExportCustoms, ExportFlavour } from "warframe-public-export-plus";
 | 
			
		||||
 | 
			
		||||
// eslint-disable-next-line @typescript-eslint/no-misused-promises
 | 
			
		||||
const inventoryController: RequestHandler = async (request, response) => {
 | 
			
		||||
@ -90,11 +85,12 @@ const inventoryController: RequestHandler = async (request, response) => {
 | 
			
		||||
    response.json(inventoryResponse);
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
/*
 | 
			
		||||
const addString = (arr: string[], str: string): void => {
 | 
			
		||||
    if (!arr.find(x => x == str)) {
 | 
			
		||||
        arr.push(str);
 | 
			
		||||
    }
 | 
			
		||||
};
 | 
			
		||||
};*/
 | 
			
		||||
 | 
			
		||||
const getExpRequiredForMr = (rank: number): number => {
 | 
			
		||||
    if (rank <= 30) {
 | 
			
		||||
 | 
			
		||||
@ -25,7 +25,7 @@ const loginController: RequestHandler = async (request, response) => {
 | 
			
		||||
                email: loginRequest.email,
 | 
			
		||||
                password: loginRequest.password,
 | 
			
		||||
                DisplayName: loginRequest.email.substring(0, loginRequest.email.indexOf("@")),
 | 
			
		||||
                Nonce: nonce,
 | 
			
		||||
                Nonce: nonce
 | 
			
		||||
            });
 | 
			
		||||
            logger.debug("created new account");
 | 
			
		||||
            // eslint-disable-next-line @typescript-eslint/no-unused-vars
 | 
			
		||||
 | 
			
		||||
@ -8,8 +8,7 @@ import { logger } from "@/src/utils/logger";
 | 
			
		||||
export const tauntHistoryController: RequestHandler = async (req, res) => {
 | 
			
		||||
    const accountId = await getAccountIdForRequest(req);
 | 
			
		||||
    const inventory = await getInventory(accountId);
 | 
			
		||||
    if(req.body !== undefined)
 | 
			
		||||
    {
 | 
			
		||||
    if (req.body !== undefined) {
 | 
			
		||||
        const clientTaunt = JSON.parse(String(req.body)) as ITaunt;
 | 
			
		||||
        logger.debug(`updating taunt ${clientTaunt.node} to state ${clientTaunt.state}`);
 | 
			
		||||
        inventory.TauntHistory ??= [];
 | 
			
		||||
@ -21,8 +20,7 @@ export const tauntHistoryController: RequestHandler = async (req, res) => {
 | 
			
		||||
        }
 | 
			
		||||
        await inventory.save();
 | 
			
		||||
        res.end();
 | 
			
		||||
    }else
 | 
			
		||||
    {
 | 
			
		||||
    } else {
 | 
			
		||||
        res.json({});
 | 
			
		||||
    }
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
@ -1,25 +1,20 @@
 | 
			
		||||
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 { getInventory } from "@/src/services/inventoryService";
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
// eslint-disable-next-line @typescript-eslint/no-misused-promises
 | 
			
		||||
export const updateInventoryController: RequestHandler = async (req, res) => {
 | 
			
		||||
    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);
 | 
			
		||||
    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();
 | 
			
		||||
    console.log(body);
 | 
			
		||||
    res.json({})
 | 
			
		||||
    res.json({});
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
/*
 | 
			
		||||
{
 | 
			
		||||
    "LongGuns" : [
 | 
			
		||||
 | 
			
		||||
@ -1,5 +1,5 @@
 | 
			
		||||
import { ILoginRequest } from "@/src/types/loginTypes";
 | 
			
		||||
import { parseEmail, parseNumber, parseString } from "./general";
 | 
			
		||||
import { parseEmail, parseString } from "./general";
 | 
			
		||||
 | 
			
		||||
const toLoginRequest = (loginRequest: unknown): ILoginRequest => {
 | 
			
		||||
    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
 | 
			
		||||
    if (
 | 
			
		||||
        "email" in loginRequest &&
 | 
			
		||||
        "password" in loginRequest
 | 
			
		||||
    ) {
 | 
			
		||||
    if ("email" in loginRequest && "password" in loginRequest) {
 | 
			
		||||
        return {
 | 
			
		||||
            email: parseEmail(loginRequest.email),
 | 
			
		||||
            password: parseString(loginRequest.password)
 | 
			
		||||
 | 
			
		||||
@ -13,30 +13,18 @@ import {
 | 
			
		||||
    IPendingRecipe as IPendingRecipeDatabase,
 | 
			
		||||
    IPendingRecipeResponse,
 | 
			
		||||
    ITypeCount,
 | 
			
		||||
    IFocusXP,
 | 
			
		||||
    IFocusUpgrades,
 | 
			
		||||
    ITypeXPItem,
 | 
			
		||||
    IChallengeProgress,
 | 
			
		||||
    IStepSequencer,
 | 
			
		||||
    IAffiliation,
 | 
			
		||||
    INotePacks,
 | 
			
		||||
    ICompletedJobChain,
 | 
			
		||||
    ISeasonChallenge,
 | 
			
		||||
    IPlayerSkills,
 | 
			
		||||
    ISettings,
 | 
			
		||||
    IInfestedFoundry,
 | 
			
		||||
    IConsumedSuit,
 | 
			
		||||
    IQuestProgress,
 | 
			
		||||
    IQuestKeyDatabase,
 | 
			
		||||
    IQuestKeyResponse,
 | 
			
		||||
    IFusionTreasure,
 | 
			
		||||
    ISpectreLoadout,
 | 
			
		||||
    IWeaponSkinDatabase,
 | 
			
		||||
    ITaunt,
 | 
			
		||||
    IPeriodicMissionCompletionDatabase,
 | 
			
		||||
    IPeriodicMissionCompletionResponse,
 | 
			
		||||
    ILoreFragmentScan,
 | 
			
		||||
    IEvolutionProgress
 | 
			
		||||
    IPeriodicMissionCompletionResponse
 | 
			
		||||
} from "../../types/inventoryTypes/inventoryTypes";
 | 
			
		||||
import { IOid } from "../../types/commonTypes";
 | 
			
		||||
import {
 | 
			
		||||
@ -53,26 +41,6 @@ import { toMongoDate, toOid } from "@/src/helpers/inventoryHelpers";
 | 
			
		||||
 | 
			
		||||
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>(
 | 
			
		||||
    {
 | 
			
		||||
        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
 | 
			
		||||
const playerSkillsSchema = new Schema<IPlayerSkills>(
 | 
			
		||||
    {
 | 
			
		||||
@ -449,25 +389,6 @@ const settingsSchema = new Schema<ISettings>({
 | 
			
		||||
    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>({
 | 
			
		||||
    c: Number,
 | 
			
		||||
    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>(
 | 
			
		||||
    {
 | 
			
		||||
        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>(
 | 
			
		||||
    {
 | 
			
		||||
        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>(
 | 
			
		||||
    {
 | 
			
		||||
        accountOwnerId: Schema.Types.ObjectId,
 | 
			
		||||
@ -656,7 +536,6 @@ const inventorySchema = new Schema<IInventoryDatabase, InventoryDocumentProps>(
 | 
			
		||||
        //Id CompletedAlerts
 | 
			
		||||
        CompletedAlerts: [String],
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
        //Resource,Credit,Affinity etc or Bless any boosters
 | 
			
		||||
        Boosters: [boosterSchema],
 | 
			
		||||
 | 
			
		||||
@ -687,7 +566,6 @@ const inventorySchema = new Schema<IInventoryDatabase, InventoryDocumentProps>(
 | 
			
		||||
        //TradeBannedUntil data
 | 
			
		||||
        TradeBannedUntil: Schema.Types.Mixed,
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
        //Unknown and system
 | 
			
		||||
        Mailbox: MailboxSchema,
 | 
			
		||||
        HandlerPoints: Number,
 | 
			
		||||
 | 
			
		||||
@ -101,16 +101,16 @@ apiRouter.get("/setSupportedSyndicate.php", setSupportedSyndicateController);
 | 
			
		||||
apiRouter.get("/surveys.php", surveysController);
 | 
			
		||||
apiRouter.get("/updateSession.php", updateSessionGetController);
 | 
			
		||||
 | 
			
		||||
apiRouter.get('/getMessages.php', (_, response) => {
 | 
			
		||||
apiRouter.get("/getMessages.php", (_, response) => {
 | 
			
		||||
    response.json({});
 | 
			
		||||
})
 | 
			
		||||
apiRouter.get('/trainingResult.php', (_, response) => {
 | 
			
		||||
});
 | 
			
		||||
apiRouter.get("/trainingResult.php", (_, response) => {
 | 
			
		||||
    response.status(200);
 | 
			
		||||
})
 | 
			
		||||
apiRouter.get('/giveStartingGear.php', (_, response) => {
 | 
			
		||||
});
 | 
			
		||||
apiRouter.get("/giveStartingGear.php", (_, response) => {
 | 
			
		||||
    response.status(200);
 | 
			
		||||
})
 | 
			
		||||
apiRouter.get('/worldState.php', worldStateController);
 | 
			
		||||
});
 | 
			
		||||
apiRouter.get("/worldState.php", worldStateController);
 | 
			
		||||
// post
 | 
			
		||||
apiRouter.post("/addFriendImage.php", addFriendImageController);
 | 
			
		||||
apiRouter.post("/artifacts.php", artifactsController);
 | 
			
		||||
 | 
			
		||||
@ -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: "./" });
 | 
			
		||||
});
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
cacheRouter.get("/H.Cache.bin!03_---------------------w", (_req, res) => {
 | 
			
		||||
    res.sendFile(`static/data/H.Cache.bin`, { root: "./" });
 | 
			
		||||
});
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user