diff --git a/apps/api/package.json b/apps/api/package.json index b70abdf..9f9aea7 100644 --- a/apps/api/package.json +++ b/apps/api/package.json @@ -8,6 +8,7 @@ "@nestjs/platform-express": "^11.0.0", "@nestjs/swagger": "^11.4.7", "@nestjs/terminus": "^11.1.1", + "@nestjs/typeorm": "^11.0.0", "axios": "^1.6.0", "colorette": "^2.0.20", "dotenv": "^16.4.7", diff --git a/apps/api/src/app/app.module.ts b/apps/api/src/app/app.module.ts index 7a93bbf..6d63b87 100644 --- a/apps/api/src/app/app.module.ts +++ b/apps/api/src/app/app.module.ts @@ -1,12 +1,14 @@ import { Module, OnModuleDestroy } from '@nestjs/common'; +import { DatabaseModule } from '../database/database.module'; +import { HealthModule } from '../health/health.module'; import { LocalLoggerModule, Logger } from '../logger'; import { AppController } from './app.controller'; import { AppService } from './app.service'; @Module({ - imports: [LocalLoggerModule.forRoot()], + imports: [LocalLoggerModule.forRoot(), DatabaseModule, HealthModule], controllers: [AppController], providers: [AppService], }) diff --git a/apps/api/src/database/database.module.ts b/apps/api/src/database/database.module.ts new file mode 100644 index 0000000..160d2d9 --- /dev/null +++ b/apps/api/src/database/database.module.ts @@ -0,0 +1,28 @@ +import { Module } from '@nestjs/common'; +import { TypeOrmModule } from '@nestjs/typeorm'; + +import AppDataSource from '../config/typeorm.config'; + +/** + * Подключение приложения к БД. + * + * Настройки берутся из того же `typeorm.config.ts`, что использует CLI миграций: + * там же загружаются env-файлы, поэтому приложению не нужен второй набор + * переменных окружения. Сущности модулей подключаются через + * `TypeOrmModule.forFeature` (autoLoadEntities), статический список `entities` + * остаётся нужен только CLI. + * + * Собственный логгер TypeORM выключен: логи приложения идут через pino + * (docs/55-logging), иначе SQL-запросы печатаются мимо него. + */ +@Module({ + imports: [ + TypeOrmModule.forRoot({ + ...AppDataSource.options, + autoLoadEntities: true, + logging: false, + migrationsRun: false, + }), + ], +}) +export class DatabaseModule {} diff --git a/apps/api/src/health/health.module.ts b/apps/api/src/health/health.module.ts new file mode 100644 index 0000000..43102bc --- /dev/null +++ b/apps/api/src/health/health.module.ts @@ -0,0 +1,10 @@ +import { Module } from '@nestjs/common'; +import { TerminusModule } from '@nestjs/terminus'; + +import { HealthController } from './health.controller'; + +@Module({ + imports: [TerminusModule], + controllers: [HealthController], +}) +export class HealthModule {} diff --git a/apps/web/src/app/app.spec.tsx b/apps/web/src/app/app.spec.tsx index 1e10d59..ac2001c 100644 --- a/apps/web/src/app/app.spec.tsx +++ b/apps/web/src/app/app.spec.tsx @@ -19,6 +19,6 @@ describe('App', () => { , ); - expect(getAllByText(new RegExp('Welcome @geo-platform/web', 'gi')).length > 0).toBeTruthy(); + expect(getAllByText(/Hello @geo-platform\/web/i).length > 0).toBeTruthy(); }); }); diff --git a/apps/web/src/app/app.tsx b/apps/web/src/app/app.tsx index 33942b1..7163af2 100644 --- a/apps/web/src/app/app.tsx +++ b/apps/web/src/app/app.tsx @@ -1,19 +1,13 @@ import { Link, Route, Routes } from 'react-router-dom'; -import NxWelcome from './nx-welcome'; +import { HealthPage } from '../pages/HealthPage'; export function App() { return (
- +

Hello @geo-platform/web

- {/* START: routes */} - {/* These routes and navigation have been generated for you */} - {/* Feel free to move and update them to fit your needs */} -
-
-
-
+
+ + - This is the generated root route.{' '} - Click here for page 2. -
- } + element={
This is the generated root route.
} + /> + } /> - Click here to go back to root page. - - } + element={
Page 2
} /> - {/* END: routes */} ); } diff --git a/apps/web/src/app/nx-welcome.tsx b/apps/web/src/app/nx-welcome.tsx deleted file mode 100644 index 60559f5..0000000 --- a/apps/web/src/app/nx-welcome.tsx +++ /dev/null @@ -1,868 +0,0 @@ -/* - * * * * * * * * * * * * * * * * * * * * * * * * * * * * - This is a starter component and can be deleted. - * * * * * * * * * * * * * * * * * * * * * * * * * * * * - Delete this file and get started with your project! - * * * * * * * * * * * * * * * * * * * * * * * * * * * * - */ -export function NxWelcome({ title }: { title: string }) { - return ( - <> -