Skip to content

Commit ff5342f

Browse files
authored
Merge pull request #262 from map-of-pi/sync-pict-changes
Self approved; retrofit Docker/ BE version changes by PiCT Tate.
2 parents 6a4b0f3 + 23f0945 commit ff5342f

File tree

6 files changed

+15
-11
lines changed

6 files changed

+15
-11
lines changed

.env.development

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@ ADMIN_API_USERNAME="ADD YOUR ADMIN API USERNAME"
1111
ADMIN_API_PASSWORD="ADD YOUR ADMIN API PASSWORD"
1212

1313
MONGODB_URL=mongodb://localhost:27017/demoDB
14+
MONGODB_MIN_POOL_SIZE=1
15+
MONGODB_MAX_POOL_SIZE=5
16+
1417
SENTRY_DSN="ADD YOUR SENTRY DSN"
1518

1619
PORT=8001

src/config/dbConnection.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,13 @@ import { env } from "../utils/env";
66
export const connectDB = async () => {
77
try {
88
// Only log the MongoDB URL in non-production environments
9-
if (process.env.NODE_ENV !== 'production') {
9+
if (env.NODE_ENV !== 'production') {
1010
logger.info(`Connecting to MongoDB with URL: ${env.MONGODB_URL}`);
1111
}
12-
await mongoose.connect(env.MONGODB_URL);
12+
await mongoose.connect(env.MONGODB_URL, {
13+
minPoolSize: env.MONGODB_MIN_POOL_SIZE,
14+
maxPoolSize: env.MONGODB_MAX_POOL_SIZE
15+
});
1316
logger.info("Successful connection to MongoDB.");
1417
} catch (error) {
1518
logger.error('Failed connection to MongoDB:', error);

src/models/Seller.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -70,13 +70,11 @@ const sellerSchema = new Schema<ISeller>(
7070
);
7171

7272
// Creating a text index on the 'name' and 'description' fields
73-
sellerSchema.index({ name: "text", description: "text" });
73+
sellerSchema.index({ 'name': 'text', 'description': 'text' });
7474

7575
// Creating a 2dsphere index for the sell_map_center field
7676
sellerSchema.index({ 'sell_map_center.coordinates': '2dsphere' });
77-
sellerSchema.index(
78-
{ 'updatedAt': -1, 'sell_map_center.coordinates': '2dsphere' }
79-
);
77+
sellerSchema.index({ 'sell_map_center': '2dsphere', 'updatedAt': -1 });
8078

8179
// Creating the Seller model from the schema
8280
const Seller = mongoose.model<ISeller>("Seller", sellerSchema);

src/utils/app.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,6 @@ app.use(cookieParser());
3333

3434
// serve static files for Swagger documentation
3535
app.use('/api/docs', express.static(path.join(__dirname, '../config/docs')));
36-
app.use('/api/docs/enum', express.static(path.join(__dirname, '../config/docs/enum')));
37-
// Serve Swagger UI static files
38-
app.use('/api/docs/swagger-ui', express.static(path.join(__dirname, '../node_modules/swagger-ui-dist')));
3936

4037
// Swagger OpenAPI documentation
4138
app.use("/api/docs", docRouter);

src/utils/env.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ export const env = {
1313
ADMIN_API_PASSWORD: process.env.ADMIN_API_PASSWORD || '',
1414
UPLOAD_PATH: process.env.UPLOAD_PATH || '',
1515
MONGODB_URL: process.env.MONGODB_URL || '',
16+
MONGODB_MIN_POOL_SIZE: Number(process.env.MONGODB_MIN_POOL_SIZE) || 1,
17+
MONGODB_MAX_POOL_SIZE: Number(process.env.MONGODB_MAX_POOL_SIZE) || 5,
1618
SENTRY_DSN: process.env.SENTRY_DSN || '',
1719
CLOUDINARY_CLOUD_NAME: process.env.CLOUDINARY_CLOUD_NAME || '',
1820
CLOUDINARY_API_KEY: process.env.CLOUDINARY_API_KEY || '',

test/services/report.service.spec.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,15 @@ jest.mock('../../src/helpers/location', () => ({
99

1010
describe('reportSanctionedSellers function', () => {
1111
it('should build sanctioned sellers report for affected sellers', async () => {
12-
( reverseLocationDetails as jest.Mock)
12+
(reverseLocationDetails as jest.Mock)
1313
.mockResolvedValueOnce({ data: { display_name: 'Cuba' } })
1414
.mockResolvedValueOnce({ data: { display_name: 'Iran' } })
1515
.mockResolvedValueOnce({ data: { display_name: 'North Korea' } })
1616
.mockResolvedValueOnce({ data: { display_name: 'Syria' } })
1717
.mockResolvedValueOnce({ data: { display_name: 'Republic of Crimea' } })
1818
.mockResolvedValueOnce({ data: { display_name: 'Donetsk Oblast' } })
19-
.mockResolvedValueOnce({ data: { display_name: 'Luhansk Oblast' } });
19+
.mockResolvedValueOnce({ data: { display_name: 'Luhansk Oblast' } })
20+
.mockResolvedValue({ data: { display_name: 'Russia' } });
2021

2122
const sanctionedSellers = await reportSanctionedSellers();
2223

0 commit comments

Comments
 (0)