Skip to content

Commit

Permalink
h5p: library management app, module, service
Browse files Browse the repository at this point in the history
  • Loading branch information
ssmid committed Aug 25, 2023
1 parent bcdde0c commit 86892dc
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 35 deletions.
32 changes: 4 additions & 28 deletions apps/server/src/apps/h5p-library-management.app.ts
Original file line number Diff line number Diff line change
@@ -1,48 +1,24 @@
/* istanbul ignore file */
/* eslint-disable no-console */
import { NestFactory } from '@nestjs/core';
import { ExpressAdapter } from '@nestjs/platform-express';
import express from 'express';

// register source-map-support for debugging
import { install as sourceMapInstall } from 'source-map-support';

// application imports
import { LegacyLogger } from '@src/core/logger';
import { H5PLibraryManagementModule } from '@src/modules/h5p-library-management/h5p-library-management.module';
import { enableOpenApiDocs } from '@src/shared/controller/swagger';
import { H5PLibraryManagementService } from '@src/modules/h5p-library-management/service/h5p-library-management.service';

async function bootstrap() {
sourceMapInstall();

// create the NestJS application on a seperate express instance
const nestExpress = express();
const nestApp = await NestFactory.createApplicationContext(H5PLibraryManagementModule);

const nestExpressAdapter = new ExpressAdapter(nestExpress);
const nestApp = await NestFactory.create(H5PLibraryManagementModule, nestExpressAdapter);
// WinstonLogger
nestApp.useLogger(await nestApp.resolve(LegacyLogger));

// customize nest app settings
nestApp.enableCors({ exposedHeaders: ['Content-Disposition'] });
enableOpenApiDocs(nestApp, 'docs');

await nestApp.init();

// mount instances
const rootExpress = express();

const port = 4499; // TODO: request port
const basePath = '/api/v3';

// exposed alias mounts
rootExpress.use(basePath, nestExpress);
rootExpress.listen(port);

console.log('##########################################');
console.log(`### Start H5P Library Management Server ###`);
console.log(`### Port: ${port} ###`);
console.log(`### Base path: ${basePath} ###`);
console.log('##########################################');
const manager = new H5PLibraryManagementService();
manager.run();
}
void bootstrap();
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,10 @@ import { RabbitMQWrapperModule } from '@shared/infra/rabbitmq';
import { DB_PASSWORD, DB_URL, DB_USERNAME } from '@src/config';
import { CoreModule } from '@src/core';
import { Logger } from '@src/core/logger';
import { AuthenticationModule } from '@src/modules/authentication/authentication.module';
import { AuthorizationModule } from '@src/modules/authorization';

import { LibraryStorage } from '../h5p-editor/service';

import { UserModule } from '..';
import { H5PLibraryManegementUc } from './uc/h5p-library-management.uc';

const defaultMikroOrmOptions: MikroOrmModuleSyncOptions = {
findOneOrFailHandler: (entityName: string, where: Dictionary | IPrimaryKey) =>
Expand All @@ -20,8 +19,6 @@ const defaultMikroOrmOptions: MikroOrmModuleSyncOptions = {
};

const imports = [
AuthenticationModule,
AuthorizationModule,
CoreModule,
UserModule,
RabbitMQWrapperModule,
Expand All @@ -36,9 +33,9 @@ const imports = [
}),
];

const controllers = [H5PLibraryManegementUc];
const controllers = [];

const providers = [Logger, H5PLibraryManegementUc];
const providers = [Logger, LibraryStorage];

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

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

0 comments on commit 86892dc

Please sign in to comment.