Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ export default [

"@typescript-eslint/no-explicit-any": "error",
"@typescript-eslint/no-inferrable-types": "error",
"@typescript-eslint/no-floating-promises": "error",
"@typescript-eslint/no-misused-promises": "error",
Comment thread
sourcery-ai[bot] marked this conversation as resolved.

quotes: [
"error",
Expand Down
48 changes: 27 additions & 21 deletions src/auth/access-group-provider/access-group-service-factory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import { Logger } from "@nestjs/common";
*/
export const accessGroupServiceFactory = {
provide: AccessGroupService,
useFactory: (configService: ConfigService) => {
useFactory: async (configService: ConfigService) => {
Logger.debug("Service factory starting", "accessGroupServiceFactory");
const accessGroupsStaticConfig = configService.get(
"accessGroupsStaticConfig",
Expand Down Expand Up @@ -68,26 +68,32 @@ export const accessGroupServiceFactory = {
"loading graphql processor",
);

import(accessGroupsGraphQlConfig.responseProcessorSrc).then(
(rpModule) => {
const gh = rpModule.graphHandler;
const responseProcessor: (
response: Record<string, unknown>,
) => string[] = gh.responseProcessor;
const graphqlTemplateQuery: string = gh.graphqlTemplateQuery;
accessGroupServices.push(
new AccessGroupFromGraphQLApiService(
graphqlTemplateQuery,
accessGroupsGraphQlConfig.apiUrl,
{
Authorization: `Bearer ${accessGroupsGraphQlConfig.token}`,
},
responseProcessor,
new HttpService(),
),
);
},
);
try {
const rpModule = await import(
accessGroupsGraphQlConfig.responseProcessorSrc
);
const gh = rpModule.graphHandler;
const responseProcessor: (
response: Record<string, unknown>,
) => string[] = gh.responseProcessor;
const graphqlTemplateQuery: string = gh.graphqlTemplateQuery;
accessGroupServices.push(
new AccessGroupFromGraphQLApiService(
graphqlTemplateQuery,
accessGroupsGraphQlConfig.apiUrl,
{
Authorization: `Bearer ${accessGroupsGraphQlConfig.token}`,
},
responseProcessor,
new HttpService(),
),
);
} catch (error) {
Logger.error(
`Failed to load graphql response processor from "${accessGroupsGraphQlConfig.responseProcessorSrc}", skipping this access group provider: ${error}`,
"accessGroupServiceFactory",
);
}
}
if (accessGroupsRestConfig?.enabled == true) {
Logger.log(
Expand Down
2 changes: 1 addition & 1 deletion src/auth/auth.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ export class AuthService {
const logoutResult = await this.additionalLogoutTasks(req, logoutURL);

if (expressSessionSecret) {
req.logout(async (err) => {
req.logout((err) => {
if (err) {
// we should provide a message
Logger.error("Logout error: ", err);
Expand Down
2 changes: 1 addition & 1 deletion src/datasets/datasets.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ import { OpensearchModule } from "src/opensearch/opensearch.module";
} else {
const regexLiteral = /(?<=AV\=)(.*?)(?=\,)/g;
av = (regexLiteral.exec(this.classification ?? "") || ["low"])[0];
policyService.addDefaultPolicy(
await policyService.addDefaultPolicy(
this.ownerGroup,
this.accessGroups,
this.ownerEmail ?? "",
Expand Down
5 changes: 4 additions & 1 deletion src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,4 +103,7 @@ async function bootstrap() {

await app.listen(port);
}
bootstrap();
bootstrap().catch((error) => {
Logger.error("Failed to bootstrap the application", error, "Main");
process.exit(1);
});
8 changes: 7 additions & 1 deletion src/opensearch/opensearch.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,13 @@ export class OpensearchService implements OnModuleInit {
}

onModuleInit() {
this.initWithRetry();
this.initWithRetry().catch((error) => {
Logger.error(
"Opensearch initialization failed unexpectedly",
error,
"Opensearch",
);
Comment thread
sourcery-ai[bot] marked this conversation as resolved.
});
}

private async connect() {
Expand Down
16 changes: 9 additions & 7 deletions src/users/users.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -142,13 +142,15 @@ export class UsersService implements OnModuleInit {
};
const createdRole = await this.rolesService.findOrCreate(createRole);
if (createdRole && userIds) {
userIds.forEach(async (userId) => {
const createUserRole: CreateUserRoleDto = {
userId: userId,
roleId: createdRole._id,
};
await this.rolesService.findOrCreateUserRole(createUserRole);
});
await Promise.all(
userIds.map(async (userId) => {
const createUserRole: CreateUserRoleDto = {
userId: userId,
roleId: createdRole._id,
};
await this.rolesService.findOrCreateUserRole(createUserRole);
}),
);
}
}
}
Expand Down
Loading