fix: migrate deprecated APIs and patch vulnerable dependencies
Use current Mongoose, NATS, React, and ESLint APIs. Upgrade Vite and other affected dependencies, restrict the compatibility plugin to resolved module IDs, and keep qs unchanged.
This commit is contained in:
1 parent
5882585f69
commit
9d7c888b0a
14 files changed
+952
-900
No files matched your search
@@ -1,3 +1,4 @@
|
||||
import os from 'node:os';
|
||||
import mongoose from 'mongoose';
|
||||
import { AuctionService } from '../src/modules/auction/auction.service';
|
||||
import { AuctionDurabilityScheduler } from '../src/modules/auction/auction-durability.scheduler';
|
||||
@@ -16,7 +17,7 @@ import {
|
||||
} from '../src/modules/global/database/schema';
|
||||
|
||||
let connection: mongoose.Connection;
|
||||
let models: Record<string, mongoose.Model<any>>;
|
||||
let models: ReturnType<typeof createModels>;
|
||||
const redis = {
|
||||
acquireTokenLock: async () => true,
|
||||
releaseTokenLock: async () => true,
|
||||
@@ -27,19 +28,8 @@ const redis = {
|
||||
}),
|
||||
};
|
||||
|
||||
beforeAll(async () => {
|
||||
if (
|
||||
process.env.MONGO_TEST_ISOLATED !== '1' ||
|
||||
!process.env.MONGO_TEST_URL?.startsWith('mongodb://127.0.0.1:')
|
||||
)
|
||||
throw new Error('Use test:mongodb with an isolated local replica set.');
|
||||
connection = await mongoose
|
||||
.createConnection(process.env.MONGO_TEST_URL, {
|
||||
autoIndex: false,
|
||||
autoCreate: false,
|
||||
})
|
||||
.asPromise();
|
||||
models = {
|
||||
function createModels(connection: mongoose.Connection) {
|
||||
return {
|
||||
match: connection.model('match', MatchSchema),
|
||||
auction: connection.model('auction', AuctionSchema),
|
||||
auctionHistory: connection.model(
|
||||
@@ -56,12 +46,29 @@ beforeAll(async () => {
|
||||
AuctionBidRecordSchema,
|
||||
),
|
||||
};
|
||||
}
|
||||
|
||||
beforeAll(async () => {
|
||||
if (
|
||||
process.env.MONGO_TEST_ISOLATED !== '1' ||
|
||||
!process.env.MONGO_TEST_URL?.startsWith('mongodb://127.0.0.1:')
|
||||
)
|
||||
throw new Error('Use test:mongodb with an isolated local replica set.');
|
||||
connection = await mongoose
|
||||
.createConnection(process.env.MONGO_TEST_URL, {
|
||||
autoIndex: false,
|
||||
autoCreate: false,
|
||||
// NODE-7832: the driver's default OS adapter breaks the Jest handshake.
|
||||
runtimeAdapters: { os },
|
||||
})
|
||||
.asPromise();
|
||||
models = createModels(connection);
|
||||
await Promise.all(
|
||||
Object.values(models).map((model) => model.createCollection()),
|
||||
);
|
||||
});
|
||||
beforeEach(async () => {
|
||||
await Promise.all(Object.values(models).map((model) => model.deleteMany({})));
|
||||
await Promise.all(Object.values(models).map((model) => model.deleteMany()));
|
||||
});
|
||||
afterEach(() => jest.restoreAllMocks());
|
||||
afterAll(async () => {
|
||||
@@ -84,7 +91,6 @@ async function fixture(reserved: boolean) {
|
||||
participants: [],
|
||||
tournamentCodeIds: reserved ? [codeId] : [],
|
||||
gameSchedule: [],
|
||||
__v: 0,
|
||||
});
|
||||
await models.auction.collection.insertOne({
|
||||
_id: auctionId,
|
||||
@@ -104,7 +110,7 @@ async function fixture(reserved: boolean) {
|
||||
matchId,
|
||||
});
|
||||
const database = {
|
||||
getModel: async (name: string) => models[name],
|
||||
getModel: async (name: keyof typeof models) => models[name],
|
||||
createSession: () => connection.startSession(),
|
||||
};
|
||||
const codes = new TournamentCodeService(database as never, redis as never);
|
||||
@@ -611,10 +617,7 @@ it('reads an uncommitted Match in the provided session when cancelling polling b
|
||||
{ session },
|
||||
);
|
||||
expect(await models.match.findById(created._id)).toBeNull();
|
||||
await f.results.cancelPolling(
|
||||
created._id as mongoose.Types.ObjectId,
|
||||
session,
|
||||
);
|
||||
await f.results.cancelPolling(created._id, session);
|
||||
expect(
|
||||
await models.match.findById(created._id).session(session),
|
||||
).not.toBeNull();
|
||||
|
||||
@@ -324,7 +324,13 @@ describe('Community Hash response cache', () => {
|
||||
|
||||
it('does not share an old in-flight detail request after invalidation or overwrite the fresh response', async () => {
|
||||
const service = new CommunityStatsService(
|
||||
{} as never,
|
||||
{
|
||||
getModel: async () => ({
|
||||
findOne: () => ({
|
||||
select: () => ({ lean: () => ({ exec: async () => null }) }),
|
||||
}),
|
||||
}),
|
||||
} as never,
|
||||
cache,
|
||||
{} as never,
|
||||
{} as never,
|
||||
|
||||
Reference in new issue
Block a user