chore: fix most explicit-function-return-type warnings
This commit is contained in:
parent
fbc66ab06f
commit
ad6c24de71
@ -1,6 +1,6 @@
|
||||
import { Request, Response } from "express";
|
||||
|
||||
const getFriendsController = (_request: Request, response: Response) => {
|
||||
const getFriendsController = (_request: Request, response: Response): void => {
|
||||
response.writeHead(200, {
|
||||
//Connection: "keep-alive",
|
||||
//"Content-Encoding": "gzip",
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { IOid } from "@/src/types/commonTypes";
|
||||
import { IMongoDate, IOid } from "@/src/types/commonTypes";
|
||||
import { IInventoryResponse } from "@/src/types/inventoryTypes/inventoryTypes";
|
||||
import { Types } from "mongoose";
|
||||
|
||||
@ -9,10 +9,10 @@ export const toInventoryResponse = (inventoryDatabase: { accountOwnerId: Types.O
|
||||
return inventoryResponse as unknown as IInventoryResponse;
|
||||
};
|
||||
|
||||
export const toOid = (objectId: Types.ObjectId) => {
|
||||
export const toOid = (objectId: Types.ObjectId): IOid => {
|
||||
return { $oid: objectId.toString() } satisfies IOid;
|
||||
};
|
||||
|
||||
export const toMongoDate = (date: Date) => {
|
||||
export const toMongoDate = (date: Date): IMongoDate => {
|
||||
return { $date: { $numberLong: date.getTime().toString() } };
|
||||
};
|
||||
|
@ -43,7 +43,7 @@ export const isSlotPurchaseName = (slotPurchaseName: string): slotPurchaseName i
|
||||
return slotPurchaseName in slotPurchaseNameToSlotName;
|
||||
};
|
||||
|
||||
export const parseSlotPurchaseName = (slotPurchaseName: string) => {
|
||||
export const parseSlotPurchaseName = (slotPurchaseName: string): SlotPurchaseName => {
|
||||
if (!isSlotPurchaseName(slotPurchaseName)) throw new Error(`invalid slot name ${slotPurchaseName}`);
|
||||
return slotPurchaseName;
|
||||
};
|
||||
|
@ -17,7 +17,7 @@ export const getSubstringFromKeywordToKeyword = (str: string, keywordBegin: stri
|
||||
return str.substring(beginIndex, endIndex + 1);
|
||||
};
|
||||
|
||||
export const getIndexAfter = (str: string, searchWord: string) => {
|
||||
export const getIndexAfter = (str: string, searchWord: string): number => {
|
||||
const index = str.indexOf(searchWord);
|
||||
if (index === -1) {
|
||||
return -1;
|
||||
|
@ -1,7 +1,7 @@
|
||||
import { logger } from "@/src/utils/logger";
|
||||
import { /*NextFunction,*/ Request, Response } from "express";
|
||||
|
||||
const unknownEndpointHandler = (request: Request, response: Response) => {
|
||||
const unknownEndpointHandler = (request: Request, response: Response): void => {
|
||||
logger.error(`unknown endpoint ${request.method} ${request.path}`);
|
||||
if (request.body) {
|
||||
logger.debug(`data provided to ${request.path}: ${String(request.body)}`);
|
||||
|
@ -316,7 +316,7 @@ const MailboxSchema = new Schema<IMailbox>(
|
||||
{
|
||||
LastInboxId: {
|
||||
type: Schema.Types.ObjectId,
|
||||
set: (v: IMailbox["LastInboxId"]) => v.$oid.toString()
|
||||
set: (v: IMailbox["LastInboxId"]): string => v.$oid.toString()
|
||||
}
|
||||
},
|
||||
{ id: false, _id: false }
|
||||
|
@ -47,7 +47,7 @@ interface ILoggerConfig {
|
||||
level: string; // "fatal" | "error" | "warn" | "info" | "http" | "debug" | "trace";
|
||||
}
|
||||
|
||||
export const updateConfig = async (data: string) => {
|
||||
export const updateConfig = async (data: string): Promise<void> => {
|
||||
amnesia = true;
|
||||
await fsPromises.writeFile(configPath, data);
|
||||
Object.assign(config, JSON.parse(data));
|
||||
|
@ -42,7 +42,7 @@ import {
|
||||
export const createInventory = async (
|
||||
accountOwnerId: Types.ObjectId,
|
||||
defaultItemReferences: { loadOutPresetId: Types.ObjectId; ship: Types.ObjectId }
|
||||
) => {
|
||||
): Promise<void> => {
|
||||
try {
|
||||
const inventory = new Inventory({
|
||||
...new_inventory,
|
||||
@ -405,7 +405,12 @@ export const addSpaceSuit = async (spacesuitName: string, accountId: string) =>
|
||||
return changedInventory.SpaceSuits[suitIndex - 1].toJSON();
|
||||
};
|
||||
|
||||
export const updateSlots = async (accountId: string, slotName: SlotNames, slotAmount: number, extraAmount: number) => {
|
||||
export const updateSlots = async (
|
||||
accountId: string,
|
||||
slotName: SlotNames,
|
||||
slotAmount: number,
|
||||
extraAmount: number
|
||||
): Promise<void> => {
|
||||
const inventory = await getInventory(accountId);
|
||||
|
||||
inventory[slotName].Slots += slotAmount;
|
||||
@ -478,7 +483,7 @@ export const updateGeneric = async (data: IGenericUpdate, accountId: string): Pr
|
||||
await inventory.save();
|
||||
};
|
||||
|
||||
export const updateTheme = async (data: IThemeUpdateRequest, accountId: string) => {
|
||||
export const updateTheme = async (data: IThemeUpdateRequest, accountId: string): Promise<void> => {
|
||||
const inventory = await getInventory(accountId);
|
||||
if (data.Style) inventory.ThemeStyle = data.Style;
|
||||
if (data.Background) inventory.ThemeBackground = data.Background;
|
||||
@ -546,7 +551,7 @@ const addGearExpByCategory = (
|
||||
inventory: IInventoryDatabaseDocument,
|
||||
gearArray: IEquipmentClient[] | undefined,
|
||||
categoryName: TEquipmentKey
|
||||
) => {
|
||||
): void => {
|
||||
const category = inventory[categoryName];
|
||||
|
||||
gearArray?.forEach(({ ItemId, XP }) => {
|
||||
@ -575,7 +580,7 @@ const addGearExpByCategory = (
|
||||
});
|
||||
};
|
||||
|
||||
export const addMiscItems = (inventory: IInventoryDatabaseDocument, itemsArray: IMiscItem[] | undefined) => {
|
||||
export const addMiscItems = (inventory: IInventoryDatabaseDocument, itemsArray: IMiscItem[] | undefined): void => {
|
||||
const { MiscItems } = inventory;
|
||||
|
||||
itemsArray?.forEach(({ ItemCount, ItemType }) => {
|
||||
@ -590,7 +595,10 @@ export const addMiscItems = (inventory: IInventoryDatabaseDocument, itemsArray:
|
||||
});
|
||||
};
|
||||
|
||||
export const addShipDecorations = (inventory: IInventoryDatabaseDocument, itemsArray: IConsumable[] | undefined) => {
|
||||
export const addShipDecorations = (
|
||||
inventory: IInventoryDatabaseDocument,
|
||||
itemsArray: IConsumable[] | undefined
|
||||
): void => {
|
||||
const { ShipDecorations } = inventory;
|
||||
|
||||
itemsArray?.forEach(({ ItemCount, ItemType }) => {
|
||||
@ -605,7 +613,7 @@ export const addShipDecorations = (inventory: IInventoryDatabaseDocument, itemsA
|
||||
});
|
||||
};
|
||||
|
||||
export const addConsumables = (inventory: IInventoryDatabaseDocument, itemsArray: IConsumable[] | undefined) => {
|
||||
export const addConsumables = (inventory: IInventoryDatabaseDocument, itemsArray: IConsumable[] | undefined): void => {
|
||||
const { Consumables } = inventory;
|
||||
|
||||
itemsArray?.forEach(({ ItemCount, ItemType }) => {
|
||||
@ -620,7 +628,7 @@ export const addConsumables = (inventory: IInventoryDatabaseDocument, itemsArray
|
||||
});
|
||||
};
|
||||
|
||||
export const addRecipes = (inventory: IInventoryDatabaseDocument, itemsArray: ITypeCount[] | undefined) => {
|
||||
export const addRecipes = (inventory: IInventoryDatabaseDocument, itemsArray: ITypeCount[] | undefined): void => {
|
||||
const { Recipes } = inventory;
|
||||
|
||||
itemsArray?.forEach(({ ItemCount, ItemType }) => {
|
||||
@ -635,7 +643,7 @@ export const addRecipes = (inventory: IInventoryDatabaseDocument, itemsArray: IT
|
||||
});
|
||||
};
|
||||
|
||||
export const addMods = (inventory: IInventoryDatabaseDocument, itemsArray: IRawUpgrade[] | undefined) => {
|
||||
export const addMods = (inventory: IInventoryDatabaseDocument, itemsArray: IRawUpgrade[] | undefined): void => {
|
||||
const { RawUpgrades } = inventory;
|
||||
itemsArray?.forEach(({ ItemType, ItemCount }) => {
|
||||
const itemIndex = RawUpgrades.findIndex(i => i.ItemType === ItemType);
|
||||
@ -652,7 +660,7 @@ export const addMods = (inventory: IInventoryDatabaseDocument, itemsArray: IRawU
|
||||
export const addFusionTreasures = (
|
||||
inventory: IInventoryDatabaseDocument,
|
||||
itemsArray: IFusionTreasure[] | undefined
|
||||
) => {
|
||||
): void => {
|
||||
const { FusionTreasures } = inventory;
|
||||
itemsArray?.forEach(({ ItemType, ItemCount, Sockets }) => {
|
||||
const itemIndex = FusionTreasures.findIndex(i => i.ItemType == ItemType && (i.Sockets || 0) == (Sockets || 0));
|
||||
@ -666,7 +674,10 @@ export const addFusionTreasures = (
|
||||
});
|
||||
};
|
||||
|
||||
export const updateChallengeProgress = async (challenges: IUpdateChallengeProgressRequest, accountId: string) => {
|
||||
export const updateChallengeProgress = async (
|
||||
challenges: IUpdateChallengeProgressRequest,
|
||||
accountId: string
|
||||
): Promise<void> => {
|
||||
const inventory = await getInventory(accountId);
|
||||
|
||||
addChallenges(inventory, challenges.ChallengeProgress);
|
||||
@ -678,7 +689,7 @@ export const updateChallengeProgress = async (challenges: IUpdateChallengeProgre
|
||||
export const addSeasonalChallengeHistory = (
|
||||
inventory: IInventoryDatabaseDocument,
|
||||
itemsArray: ISeasonChallenge[] | undefined
|
||||
) => {
|
||||
): void => {
|
||||
const category = inventory.SeasonChallengeHistory;
|
||||
|
||||
itemsArray?.forEach(({ challenge, id }) => {
|
||||
@ -692,7 +703,10 @@ export const addSeasonalChallengeHistory = (
|
||||
});
|
||||
};
|
||||
|
||||
export const addChallenges = (inventory: IInventoryDatabaseDocument, itemsArray: IChallengeProgress[] | undefined) => {
|
||||
export const addChallenges = (
|
||||
inventory: IInventoryDatabaseDocument,
|
||||
itemsArray: IChallengeProgress[] | undefined
|
||||
): void => {
|
||||
const category = inventory.ChallengeProgress;
|
||||
|
||||
itemsArray?.forEach(({ Name, Progress }) => {
|
||||
@ -707,7 +721,7 @@ export const addChallenges = (inventory: IInventoryDatabaseDocument, itemsArray:
|
||||
});
|
||||
};
|
||||
|
||||
const addMissionComplete = (inventory: IInventoryDatabaseDocument, { Tag, Completes }: IMission) => {
|
||||
const addMissionComplete = (inventory: IInventoryDatabaseDocument, { Tag, Completes }: IMission): void => {
|
||||
const { Missions } = inventory;
|
||||
const itemIndex = Missions.findIndex(item => item.Tag === Tag);
|
||||
|
||||
@ -719,7 +733,10 @@ const addMissionComplete = (inventory: IInventoryDatabaseDocument, { Tag, Comple
|
||||
}
|
||||
};
|
||||
|
||||
export const missionInventoryUpdate = async (data: IMissionInventoryUpdateRequest, accountId: string) => {
|
||||
export const missionInventoryUpdate = async (
|
||||
data: IMissionInventoryUpdateRequest,
|
||||
accountId: string
|
||||
): Promise<IInventoryChanges> => {
|
||||
const {
|
||||
RawUpgrades,
|
||||
MiscItems,
|
||||
|
@ -1,7 +1,8 @@
|
||||
import { Loadout } from "@/src/models/inventoryModels/loadoutModel";
|
||||
import { logger } from "@/src/utils/logger";
|
||||
import { ILoadoutDatabase } from "../types/saveLoadoutTypes";
|
||||
|
||||
export const getLoadout = async (accountId: string) => {
|
||||
export const getLoadout = async (accountId: string): Promise<ILoadoutDatabase> => {
|
||||
const loadout = await Loadout.findOne({ loadoutOwnerId: accountId });
|
||||
|
||||
if (!loadout) {
|
||||
@ -9,5 +10,5 @@ export const getLoadout = async (accountId: string) => {
|
||||
throw new Error("loadout not found");
|
||||
}
|
||||
|
||||
return loadout;
|
||||
return loadout.toJSON();
|
||||
};
|
||||
|
@ -29,13 +29,13 @@ export const createAccount = async (accountData: IDatabaseAccount) => {
|
||||
}
|
||||
};
|
||||
|
||||
export const createLoadout = async (accountId: Types.ObjectId) => {
|
||||
export const createLoadout = async (accountId: Types.ObjectId): Promise<Types.ObjectId> => {
|
||||
const loadout = new Loadout({ loadoutOwnerId: accountId });
|
||||
const savedLoadout = await loadout.save();
|
||||
return savedLoadout._id;
|
||||
};
|
||||
|
||||
export const createPersonalRooms = async (accountId: Types.ObjectId, shipId: Types.ObjectId) => {
|
||||
export const createPersonalRooms = async (accountId: Types.ObjectId, shipId: Types.ObjectId): Promise<void> => {
|
||||
const personalRooms = new PersonalRooms({
|
||||
...new_personal_rooms,
|
||||
personalRoomsOwnerId: accountId,
|
||||
|
@ -184,7 +184,7 @@ const addRewardResponse = (
|
||||
ItemType: string,
|
||||
ItemCount: number,
|
||||
InventoryCategory: IInventoryFieldType
|
||||
) => {
|
||||
): void => {
|
||||
if (!ItemType) return;
|
||||
|
||||
if (!InventoryChanges[InventoryCategory]) {
|
||||
|
@ -8,7 +8,7 @@ if (url === undefined) {
|
||||
throw new Error("MONGODB_URL not found. Make sure you have a .env file in the root of the project!");
|
||||
}
|
||||
|
||||
const connectDatabase = async () => {
|
||||
const connectDatabase = async (): Promise<void> => {
|
||||
try {
|
||||
await mongoose.connect(`${url}`);
|
||||
logger.info("Connected to MongoDB");
|
||||
|
@ -11,13 +11,13 @@ import { IPurchaseRequest, SlotPurchase, IInventoryChanges } from "@/src/types/p
|
||||
import { logger } from "@/src/utils/logger";
|
||||
import { ExportBundles, ExportGear, TRarity } from "warframe-public-export-plus";
|
||||
|
||||
export const getStoreItemCategory = (storeItem: string) => {
|
||||
export const getStoreItemCategory = (storeItem: string): string => {
|
||||
const storeItemString = getSubstringFromKeyword(storeItem, "StoreItems/");
|
||||
const storeItemElements = storeItemString.split("/");
|
||||
return storeItemElements[1];
|
||||
};
|
||||
|
||||
export const getStoreItemTypesCategory = (typesItem: string) => {
|
||||
export const getStoreItemTypesCategory = (typesItem: string): string => {
|
||||
const typesString = getSubstringFromKeyword(typesItem, "Types");
|
||||
const typeElements = typesString.split("/");
|
||||
if (typesItem.includes("StoreItems")) {
|
||||
@ -26,7 +26,10 @@ export const getStoreItemTypesCategory = (typesItem: string) => {
|
||||
return typeElements[1];
|
||||
};
|
||||
|
||||
export const handlePurchase = async (purchaseRequest: IPurchaseRequest, accountId: string) => {
|
||||
export const handlePurchase = async (
|
||||
purchaseRequest: IPurchaseRequest,
|
||||
accountId: string
|
||||
): Promise<{ InventoryChanges: IInventoryChanges }> => {
|
||||
logger.debug("purchase request", purchaseRequest);
|
||||
|
||||
const purchaseResponse = await handleStoreItemAcquisition(
|
||||
|
@ -4,7 +4,7 @@ import { getRecipe } from "@/src/services/itemDataService";
|
||||
import { logger } from "@/src/utils/logger";
|
||||
import { Types } from "mongoose";
|
||||
|
||||
export const startRecipe = async (recipeName: string, accountId: string) => {
|
||||
export const startRecipe = async (recipeName: string, accountId: string): Promise<{ RecipeId: { $oid?: string } }> => {
|
||||
const recipe = getRecipe(recipeName);
|
||||
|
||||
if (!recipe) {
|
||||
|
@ -10,7 +10,7 @@ import {
|
||||
import { logger } from "@/src/utils/logger";
|
||||
import { Types } from "mongoose";
|
||||
|
||||
export const setShipCustomizations = async (shipCustomization: ISetShipCustomizationsRequest) => {
|
||||
export const setShipCustomizations = async (shipCustomization: ISetShipCustomizationsRequest): Promise<void> => {
|
||||
const ship = await getShip(new Types.ObjectId(shipCustomization.ShipId));
|
||||
|
||||
let shipChanges: Partial<IShipDatabase>;
|
||||
|
@ -3,7 +3,7 @@ import { ILoadoutDatabase } from "@/src/types/saveLoadoutTypes";
|
||||
import { logger } from "@/src/utils/logger";
|
||||
import { Types } from "mongoose";
|
||||
|
||||
export const createShip = async (accountOwnerId: Types.ObjectId) => {
|
||||
export const createShip = async (accountOwnerId: Types.ObjectId): Promise<Types.ObjectId> => {
|
||||
try {
|
||||
const ship = new Ship({
|
||||
ItemType: "/Lotus/Types/Items/Ships/DefaultShip",
|
||||
|
@ -103,7 +103,7 @@ export const logger = createLogger({
|
||||
|
||||
addColors(logLevels.colors);
|
||||
|
||||
export function registerLogFileCreationListener() {
|
||||
export function registerLogFileCreationListener(): void {
|
||||
errorLog.on("new", filename => logger.info(`Using error log file: ${filename}`));
|
||||
combinedLog.on("new", filename => logger.info(`Using combined log file: ${filename}`));
|
||||
errorLog.on("rotate", filename => logger.info(`Rotated error log file: ${filename}`));
|
||||
|
Loading…
x
Reference in New Issue
Block a user