fix return types

This commit is contained in:
Ângelo Tadeucci 2023-06-04 19:42:08 -03:00
parent 4ea70c18ee
commit 4232fad4ac
5 changed files with 23 additions and 20 deletions

View File

@ -63,8 +63,12 @@ function getSession(sessionIdOrRequest: string | FindSessionRequest): {
const request = sessionIdOrRequest;
const matchingSessions = sessions.filter(session => {
for (const key in request) {
if (key !== "eloRating" && key !== "queryId" && request[key] !== session[key as keyof Session]) {
for (const key of Object.keys(request)) {
if (
key !== "eloRating" &&
key !== "queryId" &&
request[key as keyof FindSessionRequest] !== session[key as keyof Session]
) {
return false;
}
}

View File

@ -1,6 +1,5 @@
import { Schema, model } from "mongoose";
import { IInventoryDatabase, ISuitDatabase } from "../types/inventoryTypes";
import { Oid } from "../types/commonTypes";
const polaritySchema = new Schema({
Slot: Number,
@ -66,9 +65,10 @@ const suitSchema = new Schema({
});
suitSchema.set("toJSON", {
transform(_document, returnedObject) {
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-call
returnedObject.ItemId = { $oid: returnedObject._id.toString() } satisfies Oid;
transform(_document, returnedObject: ISuitDatabase) {
if (returnedObject._id) {
returnedObject.ItemId = { $oid: returnedObject._id.toString() };
}
delete returnedObject._id;
delete returnedObject.__v;
}

View File

@ -1,6 +1,5 @@
import { IShipDatabase, IShipResponse } from "@/src/types/shipTypes";
import { Schema, model } from "mongoose";
import { IShipDatabase } from "../types/shipTypes";
import { Oid } from "../types/commonTypes";
const roomSchema = new Schema({
Name: String,
@ -31,9 +30,10 @@ const shipDatabaseSchema = new Schema({
});
shipDatabaseSchema.set("toJSON", {
transform(_document, returnedObject) {
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-call
returnedObject.Ship.ShipId = { $oid: returnedObject._id.toString() } satisfies Oid;
transform(_document, returnedObject: IShipResponse) {
if (returnedObject._id) {
returnedObject.Ship.ShipId = { $oid: returnedObject._id.toString() };
}
delete returnedObject._id;
delete returnedObject.Ship._id;
delete returnedObject.Apartment._id;

View File

@ -1,6 +1,6 @@
/* eslint-disable @typescript-eslint/no-explicit-any */
import { Document, Types } from "mongoose";
import { Types } from "mongoose";
import { Oid } from "./commonTypes";
export interface IInventoryDatabase extends IInventoryResponse {
@ -1159,12 +1159,6 @@ export interface NotePacks {
PERCUSSION: string;
}
export interface ISuitDocument extends ISuitDatabase, Document {}
export interface ISuitResponse extends ISuitDatabase {
ItemId: Oid;
}
export interface ISuitDatabase {
ItemType: string;
Configs: SuitConfig[];
@ -1178,6 +1172,8 @@ export interface ISuitDatabase {
ItemId: Oid;
FocusLens?: string;
UnlockLevel?: number;
_id?: Oid;
__v?: number;
}
export interface SuitConfig {

View File

@ -1,7 +1,6 @@
/* eslint-disable @typescript-eslint/no-explicit-any */
import { Oid } from "@/src/types/commonTypes";
import { Types } from "mongoose";
import { Oid } from "./inventoryTypes";
export type IShipDatabase = IShipResponse;
@ -9,6 +8,8 @@ export interface IShipResponse {
ShipOwnerId: Types.ObjectId;
Ship: IShipClass;
Apartment: IApartmentClass;
_id?: Types.ObjectId;
__v?: number;
}
export interface IShipClass {
@ -16,6 +17,7 @@ export interface IShipClass {
ShipId: Oid;
Features: string[];
ContentUrlSignature: string;
_id?: Types.ObjectId;
}
export interface IRoomsClass {
@ -26,4 +28,5 @@ export interface IRoomsClass {
export interface IApartmentClass {
Rooms: IRoomsClass[];
FavouriteLoadouts: string[];
_id?: Types.ObjectId;
}