forked from OpenWF/SpaceNinjaServer
		
	chore: resolve various eslint complaints (#169)
This commit is contained in:
		
							parent
							
								
									70c9a5013d
								
							
						
					
					
						commit
						9f0317fed2
					
				@ -8,6 +8,7 @@
 | 
			
		||||
    "dev": "ts-node-dev --openssl-legacy-provider -r tsconfig-paths/register src/index.ts ",
 | 
			
		||||
    "build": "tsc",
 | 
			
		||||
    "lint": "eslint --ext .ts .",
 | 
			
		||||
    "lint:fix": "eslint --fix --ext .ts .",
 | 
			
		||||
    "prettier": "prettier --write ."
 | 
			
		||||
  },
 | 
			
		||||
  "license": "GNU",
 | 
			
		||||
 | 
			
		||||
@ -6,7 +6,7 @@ import { getInventory } from "@/src/services/inventoryService";
 | 
			
		||||
const addFriendImageController: RequestHandler = async (req, res) => {
 | 
			
		||||
    const accountId = req.query.accountId as string;
 | 
			
		||||
    const json = getJSONfromString(req.body.toString()) as IUpdateGlyphRequest;
 | 
			
		||||
    let inventory = await getInventory(accountId);
 | 
			
		||||
    const inventory = await getInventory(accountId);
 | 
			
		||||
    inventory.ActiveAvatarImageType = json.AvatarImageType;
 | 
			
		||||
    await inventory.save();
 | 
			
		||||
    res.json({});
 | 
			
		||||
 | 
			
		||||
@ -1,7 +1,7 @@
 | 
			
		||||
//this is a controller for the claimCompletedRecipe route
 | 
			
		||||
//it will claim a recipe for the user
 | 
			
		||||
 | 
			
		||||
import { Request, RequestHandler, Response } from "express";
 | 
			
		||||
import { RequestHandler } from "express";
 | 
			
		||||
import { logger } from "@/src/utils/logger";
 | 
			
		||||
import { getItemByBlueprint, getItemCategoryByUniqueName } from "@/src/services/itemDataService";
 | 
			
		||||
import { IOid } from "@/src/types/commonTypes";
 | 
			
		||||
 | 
			
		||||
@ -5,16 +5,16 @@ import { Guild } from "@/src/models/guildModel";
 | 
			
		||||
import { IGuild, ICreateGuildRequest } from "@/src/types/guildTypes";
 | 
			
		||||
 | 
			
		||||
const createGuildController: RequestHandler = async (req, res) => {
 | 
			
		||||
    let payload: ICreateGuildRequest = getJSONfromString(req.body.toString());
 | 
			
		||||
    const payload: ICreateGuildRequest = getJSONfromString(req.body.toString());
 | 
			
		||||
 | 
			
		||||
    // Create guild on database
 | 
			
		||||
    let guild = new Guild({
 | 
			
		||||
    const guild = new Guild({
 | 
			
		||||
        Name: payload.guildName
 | 
			
		||||
    } satisfies IGuild);
 | 
			
		||||
    await guild.save();
 | 
			
		||||
 | 
			
		||||
    // Update inventory
 | 
			
		||||
    let inventory = await Inventory.findOne({ accountOwnerId: req.query.accountId });
 | 
			
		||||
    const inventory = await Inventory.findOne({ accountOwnerId: req.query.accountId });
 | 
			
		||||
    if (inventory) {
 | 
			
		||||
        // Set GuildId
 | 
			
		||||
        inventory.GuildId = guild._id;
 | 
			
		||||
 | 
			
		||||
@ -6,23 +6,23 @@ import { logger } from "@/src/utils/logger";
 | 
			
		||||
const findSessionsController: RequestHandler = (_req, res) => {
 | 
			
		||||
    const reqBody = JSON.parse(_req.body);
 | 
			
		||||
    logger.debug("FindSession Request ", { reqBody });
 | 
			
		||||
    let req = JSON.parse(_req.body);
 | 
			
		||||
    const req = JSON.parse(_req.body);
 | 
			
		||||
    if (req.id != undefined) {
 | 
			
		||||
        logger.debug("Found ID");
 | 
			
		||||
        let session = getSession(req.id);
 | 
			
		||||
        const session = getSession(req.id);
 | 
			
		||||
 | 
			
		||||
        if (session) res.json({ queryId: req.queryId, Sessions: session });
 | 
			
		||||
        else res.json({});
 | 
			
		||||
    } else if (req.originalSessionId != undefined) {
 | 
			
		||||
        logger.debug("Found OriginalSessionID");
 | 
			
		||||
 | 
			
		||||
        let session = getSession(req.originalSessionId);
 | 
			
		||||
        const session = getSession(req.originalSessionId);
 | 
			
		||||
        if (session) res.json({ queryId: req.queryId, Sessions: session });
 | 
			
		||||
        else res.json({});
 | 
			
		||||
    } else {
 | 
			
		||||
        logger.debug("Found SessionRequest");
 | 
			
		||||
 | 
			
		||||
        let session = getSession(_req.body);
 | 
			
		||||
        const session = getSession(_req.body);
 | 
			
		||||
        if (session) res.json({ queryId: req.queryId, Sessions: session });
 | 
			
		||||
        else res.json({});
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
@ -6,7 +6,7 @@ import { ISession } from "@/src/types/session";
 | 
			
		||||
const hostSessionController: RequestHandler = (req, res) => {
 | 
			
		||||
    const hostSessionRequest = JSON.parse(req.body as string) as ISession;
 | 
			
		||||
    logger.debug("HostSession Request", { hostSessionRequest });
 | 
			
		||||
    let session = createNewSession(hostSessionRequest, req.query.accountId as string);
 | 
			
		||||
    const session = createNewSession(hostSessionRequest, req.query.accountId as string);
 | 
			
		||||
    logger.debug(`New Session Created`, { session });
 | 
			
		||||
 | 
			
		||||
    res.json({ sessionId: { $oid: session.sessionId }, rewardSeed: 99999999 });
 | 
			
		||||
 | 
			
		||||
@ -1,5 +1,5 @@
 | 
			
		||||
import { parseString } from "@/src/helpers/general";
 | 
			
		||||
import { getInventory, updateCurrency } from "@/src/services/inventoryService";
 | 
			
		||||
import { updateCurrency } from "@/src/services/inventoryService";
 | 
			
		||||
import { RequestHandler } from "express";
 | 
			
		||||
import { updateSlots } from "@/src/services/inventoryService";
 | 
			
		||||
import { SlotNameToInventoryName } from "@/src/types/purchaseTypes";
 | 
			
		||||
 | 
			
		||||
@ -5,8 +5,8 @@ import { logger } from "@/src/utils/logger";
 | 
			
		||||
const joinSessionController: RequestHandler = (_req, res) => {
 | 
			
		||||
    const reqBody = JSON.parse(_req.body);
 | 
			
		||||
    logger.debug(`JoinSession Request`, { reqBody });
 | 
			
		||||
    let req = JSON.parse(_req.body);
 | 
			
		||||
    let session = getSessionByID(req.sessionIds[0]);
 | 
			
		||||
    const req = JSON.parse(_req.body);
 | 
			
		||||
    const session = getSessionByID(req.sessionIds[0]);
 | 
			
		||||
    res.json({ rewardSeed: session?.rewardSeed, sessionId: { $oid: session?.sessionId } });
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -1,5 +1,4 @@
 | 
			
		||||
import { RequestHandler } from "express";
 | 
			
		||||
import util from "util";
 | 
			
		||||
import { ISaveLoadoutRequest } from "@/src/types/saveLoadoutTypes";
 | 
			
		||||
import { handleInventoryItemConfigChange } from "@/src/services/saveLoadoutService";
 | 
			
		||||
import { parseString } from "@/src/helpers/general";
 | 
			
		||||
 | 
			
		||||
@ -1,6 +1,5 @@
 | 
			
		||||
import { parseString } from "@/src/helpers/general";
 | 
			
		||||
import { getJSONfromString } from "@/src/helpers/stringHelpers";
 | 
			
		||||
import { Inventory } from "@/src/models/inventoryModels/inventoryModel";
 | 
			
		||||
import { getInventory } from "@/src/services/inventoryService";
 | 
			
		||||
import { IMongoDate } from "@/src/types/commonTypes";
 | 
			
		||||
import { RequestHandler } from "express";
 | 
			
		||||
 | 
			
		||||
@ -1,6 +1,5 @@
 | 
			
		||||
import { RequestHandler } from "express";
 | 
			
		||||
import { updateSession } from "@/src/managers/sessionManager";
 | 
			
		||||
import { logger } from "@/src/utils/logger";
 | 
			
		||||
 | 
			
		||||
const updateSessionGetController: RequestHandler = (_req, res) => {
 | 
			
		||||
    res.json({});
 | 
			
		||||
 | 
			
		||||
@ -1,5 +1,4 @@
 | 
			
		||||
import { RequestHandler } from "express";
 | 
			
		||||
import config from "@/config.json";
 | 
			
		||||
import worldState from "@/static/fixed_responses/worldState.json";
 | 
			
		||||
 | 
			
		||||
const worldStateController: RequestHandler = (_req, res) => {
 | 
			
		||||
 | 
			
		||||
@ -5,7 +5,7 @@ import view from "@/static/fixed_responses/view.json";
 | 
			
		||||
import allScans from "@/static/fixed_responses/allScans.json";
 | 
			
		||||
 | 
			
		||||
const viewController: RequestHandler = (_req, res) => {
 | 
			
		||||
    let responseJson: IStatsView = view;
 | 
			
		||||
    const responseJson: IStatsView = view;
 | 
			
		||||
    if (config.unlockAllScans) {
 | 
			
		||||
        responseJson.Scans = allScans;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
@ -1,5 +1,4 @@
 | 
			
		||||
import { parseBoolean, parseNumber, parseString } from "@/src/helpers/general";
 | 
			
		||||
import { weapons } from "@/src/services/itemDataService";
 | 
			
		||||
import { slotPurchaseNameToSlotName } from "@/src/services/purchaseService";
 | 
			
		||||
import { IPurchaseRequest, SlotPurchaseName } from "@/src/types/purchaseTypes";
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -1,4 +1,4 @@
 | 
			
		||||
export const getJSONfromString = (str: string) => {
 | 
			
		||||
export const getJSONfromString = (str: string): any => {
 | 
			
		||||
    const jsonSubstring = str.substring(0, str.lastIndexOf("}") + 1);
 | 
			
		||||
    return JSON.parse(jsonSubstring);
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
@ -60,7 +60,7 @@ function getSession(sessionIdOrRequest: string | IFindSessionRequest): any[] {
 | 
			
		||||
        return [];
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    const request = sessionIdOrRequest as IFindSessionRequest;
 | 
			
		||||
    const request = sessionIdOrRequest;
 | 
			
		||||
    const matchingSessions = sessions.filter(session => {
 | 
			
		||||
        for (const key in request) {
 | 
			
		||||
            if (key !== "eloRating" && key !== "queryId" && request[key] !== session[key as keyof ISession]) {
 | 
			
		||||
 | 
			
		||||
@ -1,5 +1,5 @@
 | 
			
		||||
import { logger } from "@/src/utils/logger";
 | 
			
		||||
import { NextFunction, Request, Response } from "express";
 | 
			
		||||
import { /*NextFunction,*/ Request, Response } from "express";
 | 
			
		||||
 | 
			
		||||
const unknownEndpointHandler = (request: Request, response: Response) => {
 | 
			
		||||
    logger.error(`unknown endpoint ${request.method} ${request.path}`);
 | 
			
		||||
 | 
			
		||||
@ -38,7 +38,7 @@ import {
 | 
			
		||||
    IPeriodicMissionCompletionResponse,
 | 
			
		||||
    ILoreFragmentScan
 | 
			
		||||
} from "../../types/inventoryTypes/inventoryTypes";
 | 
			
		||||
import { IMongoDate, IOid } from "../../types/commonTypes";
 | 
			
		||||
import { IOid } from "../../types/commonTypes";
 | 
			
		||||
import { ISuitDatabase } from "@/src/types/inventoryTypes/SuitTypes";
 | 
			
		||||
import { IWeaponDatabase } from "@/src/types/inventoryTypes/weaponTypes";
 | 
			
		||||
import {
 | 
			
		||||
 | 
			
		||||
@ -1,5 +1,5 @@
 | 
			
		||||
import { Model, Schema, StringSchemaDefinition, Types, model } from "mongoose";
 | 
			
		||||
import { IApartment, IPlacedDecosDatabase, IRooms, IShipDatabase } from "../types/shipTypes";
 | 
			
		||||
import { Schema, model } from "mongoose";
 | 
			
		||||
import { IShipDatabase } from "../types/shipTypes";
 | 
			
		||||
import { toOid } from "@/src/helpers/inventoryHelpers";
 | 
			
		||||
import { colorSchema } from "@/src/models/inventoryModels/inventoryModel";
 | 
			
		||||
import { IShipInventory } from "@/src/types/inventoryTypes/inventoryTypes";
 | 
			
		||||
 | 
			
		||||
@ -1,6 +1,6 @@
 | 
			
		||||
import { unixTimesInMs } from "@/src/constants/timeConstants";
 | 
			
		||||
import { getInventory } from "@/src/services/inventoryService";
 | 
			
		||||
import { getItemByBlueprint, getItemCategoryByUniqueName } from "@/src/services/itemDataService";
 | 
			
		||||
import { getItemByBlueprint } from "@/src/services/itemDataService";
 | 
			
		||||
import { logger } from "@/src/utils/logger";
 | 
			
		||||
import { Types } from "mongoose";
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -1,6 +1,3 @@
 | 
			
		||||
import { Types } from "mongoose";
 | 
			
		||||
import { IOid } from "@/src/types/commonTypes";
 | 
			
		||||
 | 
			
		||||
export interface IGuild {
 | 
			
		||||
    Name: string;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@ -11,7 +11,6 @@ import {
 | 
			
		||||
} from "@/src/types/inventoryTypes/commonInventoryTypes";
 | 
			
		||||
import { ISuitDatabase } from "@/src/types/inventoryTypes/SuitTypes";
 | 
			
		||||
import { IOperatorLoadOutSigcol, IWeaponDatabase } from "@/src/types/inventoryTypes/weaponTypes";
 | 
			
		||||
import { Colour } from "warframe-items";
 | 
			
		||||
 | 
			
		||||
//Document extends will be deleted soon. TODO: delete and migrate uses to ...
 | 
			
		||||
export interface IInventoryDatabaseDocument extends IInventoryDatabase, Document {}
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user