From db4eb04092304fa8e55ef79276687b8940e9f65b Mon Sep 17 00:00:00 2001 From: Arswarog Date: Tue, 27 Oct 2026 09:16:14 +0300 Subject: [PATCH] =?UTF-8?q?all:=20health-=D0=BF=D1=80=D0=BE=D0=B2=D0=B5?= =?UTF-8?q?=D1=80=D0=BA=D0=B0=20api=20=D0=B8=20=D1=81=D1=82=D1=80=D0=B0?= =?UTF-8?q?=D0=BD=D0=B8=D1=86=D0=B0=20/health=20=D0=B2=20web?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/api/package.json | 1 + apps/api/src/app/app.module.ts | 4 +- apps/api/src/database/database.module.ts | 28 + apps/api/src/health/health.module.ts | 10 + apps/web/src/app/app.spec.tsx | 2 +- apps/web/src/app/app.tsx | 36 +- apps/web/src/app/nx-welcome.tsx | 868 ----------------------- apps/web/src/pages/HealthPage.spec.tsx | 30 + apps/web/src/pages/HealthPage.tsx | 2 +- yarn.lock | 5 + 10 files changed, 93 insertions(+), 893 deletions(-) create mode 100644 apps/api/src/database/database.module.ts create mode 100644 apps/api/src/health/health.module.ts delete mode 100644 apps/web/src/app/nx-welcome.tsx create mode 100644 apps/web/src/pages/HealthPage.spec.tsx 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 ( - <> -