Skip to content

Commit 8410f69

Browse files
authored
Various Refactorings (#224)
1 parent 66f0f87 commit 8410f69

3 files changed

Lines changed: 68 additions & 12 deletions

File tree

‎packages/analytics-service/src/modules/analytics/analytics.service.ts‎

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -282,16 +282,20 @@ export class AnalyticsService implements OnModuleInit {
282282
}
283283

284284
const { category, subcategory, properties } = event;
285-
const response = await logger.logCustomEvent(
286-
category,
287-
subcategory,
288-
properties,
289-
);
285+
let response;
286+
try {
287+
response = await logger.logCustomEvent(category, subcategory, properties);
288+
} catch (error: any) {
289+
throw new RpcException({
290+
code: status.INVALID_ARGUMENT,
291+
message: `Failed to log custom event: ${error?.message || error?.toString() || 'Unknown error'}..`,
292+
});
293+
}
290294

291295
if (!response) {
292296
throw new RpcException({
293297
code: status.INVALID_ARGUMENT,
294-
message: 'Invalid analytics configuration',
298+
message: `Invalid analytics configuration for custom event: ${category} ${subcategory}`,
295299
});
296300
}
297301

‎packages/api-gateway/src/main.ts‎

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,6 @@ async function bootstrap() {
2020
app.useGlobalPipes(
2121
new ValidationPipe({
2222
transform: true,
23-
transformOptions: {
24-
enableImplicitConversion: true,
25-
},
2623
}),
2724
);
2825

‎packages/db-service/src/modules/file_config/file_config.controller.ts‎

Lines changed: 58 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { status } from '@grpc/grpc-js';
22
import { Controller } from '@nestjs/common';
33
import { RpcException } from '@nestjs/microservices';
44
import { Prisma } from '@prisma/client';
5-
import { FileConfigProto } from 'juno-proto';
5+
import { FileBucketProto, FileConfigProto, FileProto } from 'juno-proto';
66
import { FileServiceConfigService } from './file_config.service';
77

88
@Controller()
@@ -61,11 +61,66 @@ export class FileConfigController
6161
});
6262
}
6363

64+
// TODO: find a way to hook this up with the standard proto definitions
65+
type PrismaConfigWithRelations = {
66+
id: number;
67+
environment: string;
68+
FileServiceFile: Array<{
69+
path: string;
70+
bucketName: string;
71+
configId: number;
72+
configEnv: string;
73+
metadata: string;
74+
}>;
75+
buckets: Array<{
76+
name: string;
77+
configId: number;
78+
configEnv: string;
79+
fileProviderName: string;
80+
}>;
81+
};
82+
83+
const prismaConfig = config as unknown as PrismaConfigWithRelations;
84+
85+
const files: FileProto.File[] = (prismaConfig.FileServiceFile ?? []).map(
86+
(f) => ({
87+
fileId: {
88+
path: f.path,
89+
bucketName: f.bucketName,
90+
configId: f.configId,
91+
configEnv: f.configEnv,
92+
},
93+
metadata: f.metadata,
94+
}),
95+
);
96+
97+
const buckets: FileBucketProto.Bucket[] = (prismaConfig.buckets ?? []).map(
98+
(b) => ({
99+
name: b.name,
100+
configId: b.configId,
101+
configEnv: b.configEnv,
102+
fileProviderName: b.fileProviderName,
103+
FileServiceFile: (prismaConfig.FileServiceFile ?? [])
104+
.filter(
105+
(f) =>
106+
f.bucketName === b.name &&
107+
f.configId === b.configId &&
108+
f.configEnv === b.configEnv,
109+
)
110+
.map((f) => ({
111+
path: f.path,
112+
bucketName: f.bucketName,
113+
configId: f.configId,
114+
configEnv: f.configEnv,
115+
})),
116+
}),
117+
);
118+
64119
return {
65120
id: config.id,
66121
environment: config.environment,
67-
files: [],
68-
buckets: [],
122+
files,
123+
buckets,
69124
};
70125
}
71126

0 commit comments

Comments
 (0)