Skip to content

Commit c9f4db9

Browse files
committed
fix(ts): fix failing tests and type errors
1 parent 0d4d874 commit c9f4db9

File tree

3 files changed

+12
-8
lines changed

3 files changed

+12
-8
lines changed

src/db/mongo/helper.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,19 @@
11
import { MongoClient, Db, Collection, Filter, Document, FindOptions } from 'mongodb';
2-
import config from '../../config';
2+
import { getDatabase } from '../../config';
33
import MongoDBStore from 'connect-mongo';
44

5-
const dbConfig = config.getDatabase();
5+
const dbConfig = getDatabase();
66
const connectionString = dbConfig.connectionString;
77
const options = dbConfig.options;
88

99
let _db: Db | null = null;
1010

1111
export const connect = async (collectionName: string): Promise<Collection> => {
1212
if (!_db) {
13+
if (!connectionString) {
14+
throw new Error('MongoDB connection string is not provided');
15+
}
16+
1317
const client = new MongoClient(connectionString, options);
1418
await client.connect();
1519
_db = client.db();

src/proxy/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ const start = async () => {
7373
return app;
7474
};
7575

76-
export {
76+
export default {
7777
proxyPreparations,
7878
createApp,
7979
start

test/chain.test.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -53,17 +53,17 @@ describe('proxy chain', function () {
5353
let processors;
5454
let chain;
5555

56-
beforeEach(() => {
57-
// Re-require the processors module after clearing the cache
58-
processors = require('../src/proxy/processors');
56+
beforeEach(async () => {
57+
// Re-import the processors module after clearing the cache
58+
processors = await import('../src/proxy/processors');
5959

6060
// Mock the processors module
6161
sinon.stub(processors, 'pre').value(mockPreProcessors);
6262

6363
sinon.stub(processors, 'push').value(mockPushProcessors);
6464

65-
// Re-require the chain module after stubbing processors
66-
chain = require('../src/proxy/chain');
65+
// Re-import the chain module after stubbing processors
66+
chain = (await import('../src/proxy/chain')).default;
6767

6868
chain.chainPluginLoader = new PluginLoader([]);
6969
});

0 commit comments

Comments
 (0)