Skip to content

Commit

Permalink
h5p lib manage: fixes for dummy run
Browse files Browse the repository at this point in the history
  • Loading branch information
ssmid committed Aug 31, 2023
1 parent c49f7ed commit cea221f
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 10 deletions.
10 changes: 6 additions & 4 deletions apps/server/src/apps/h5p-library-management.app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,14 @@ import { H5PLibraryManagementService } from '@src/modules/h5p-library-management
async function bootstrap() {
sourceMapInstall();

const nestApp = await NestFactory.createApplicationContext(H5PLibraryManagementModule);
const app = await NestFactory.createApplicationContext(H5PLibraryManagementModule);

// WinstonLogger
nestApp.useLogger(await nestApp.resolve(LegacyLogger));
app.useLogger(await app.resolve(LegacyLogger));

const manager = new H5PLibraryManagementService();
manager.run();
await app.get(H5PLibraryManagementService).run();
// TODO: properly close app (there is some issue with the logger)
// await app.close();
process.exit(0);
}
void bootstrap();
Original file line number Diff line number Diff line change
@@ -1,16 +1,22 @@
import { Dictionary, IPrimaryKey } from '@mikro-orm/core';
import { MikroOrmModule, MikroOrmModuleSyncOptions } from '@mikro-orm/nestjs';
import { Module, NotFoundException } from '@nestjs/common';
import { ConfigModule } from '@nestjs/config';
import { Account, Role, School, SchoolYear, System, User } from '@shared/domain';
import { RabbitMQWrapperModule } from '@shared/infra/rabbitmq';

import { DB_PASSWORD, DB_URL, DB_USERNAME } from '@src/config';
import { DB_PASSWORD, DB_URL, DB_USERNAME, createConfigModuleOptions } from '@src/config';
import { CoreModule } from '@src/core';
import { Logger } from '@src/core/logger';
import { LegacyLogger, Logger } from '@src/core/logger';
import { UserModule } from '..';

import { LibraryStorage } from '../h5p-editor/service';
import { config, s3ConfigLibraries } from '../h5p-editor/h5p-editor.config';
import { LibraryRepo } from '../h5p-editor/repo';
import { createS3ClientAdapter } from '../h5p-editor';

import { UserModule } from '..';
import { H5PLibraryManagementService } from './service/h5p-library-management.service';
import { InstalledLibrary } from '../h5p-editor/entity';

const defaultMikroOrmOptions: MikroOrmModuleSyncOptions = {
findOneOrFailHandler: (entityName: string, where: Dictionary | IPrimaryKey) =>
Expand All @@ -29,13 +35,29 @@ const imports = [
clientUrl: DB_URL,
password: DB_PASSWORD,
user: DB_USERNAME,
entities: [User, Account, Role, School, System, SchoolYear],
allowGlobalContext: true,
entities: [User, Account, Role, School, System, SchoolYear, InstalledLibrary],
}),
ConfigModule.forRoot(createConfigModuleOptions(config)),
];

const controllers = [];

const providers = [Logger, LibraryStorage];
const providers = [
Logger,
H5PLibraryManagementService,
LibraryRepo,
LibraryStorage,
{
provide: 'S3Config_Libraries',
useValue: s3ConfigLibraries,
},
{
provide: 'S3ClientAdapter_Libraries',
useFactory: createS3ClientAdapter,
inject: ['S3Config_Libraries', LegacyLogger],
},
];

@Module({
imports,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@ import { Injectable } from '@nestjs/common';

@Injectable()
export class H5PLibraryManagementService {
run() {
async run() {
// for debugging only
// eslint-disable-next-line no-console
console.log('Hello from H5PLibraryManagementService');
return Promise.resolve();
}
}

0 comments on commit cea221f

Please sign in to comment.