12 Commits

Author SHA1 Message Date
Первов Артем
5e98348cac удаление docker-compose.dev.yml. Удаление container_name из docker-compose. Удаление branch env переменной. 2026-07-04 20:00:39 +03:00
Первов Артем
3bf4cebbe6 Merge branch 'main' into dev 2026-07-04 18:01:41 +03:00
Первов Артем
907c24c45b docker-compose.dev.yml добавил. Временное решение. 2026-07-04 14:26:22 +03:00
Первов Артем
b057ea154a Удалил docker-compose.dev.yml. поменял наименование контейнера. Убрал дебаг логи. 2026-07-04 14:06:53 +03:00
Первов Артем
0e2a7eeeec docker-compose для дев окружения 2026-07-03 21:21:21 +03:00
Первов Артем
c702946393 обновлено логирование 2026-07-03 19:33:28 +03:00
Первов Артем
5260b8a9c5 Merge branch 'dev' of https://git.greact.ru/APervov/cloud-v3 into dev 2026-07-03 17:35:13 +03:00
Первов Артем
30bd7a0d28 добавлен лог для входящих запросов 2026-07-03 17:34:32 +03:00
32ea0d7c4d Merge branch 'dev' 2026-07-03 13:16:43 +05:00
c22d1b5b8c Merge pull request 'CORS problem solution' (#2) from cors into dev
Reviewed-on: #2
2026-07-03 07:58:02 +00:00
56e90a54d8 CORS problem solution 2026-07-03 12:54:23 +05:00
15fe566d53 Merge pull request 'Убран лишний код. Скорректированы docker и package файлы. Переработано взаимодействие с бд - упрощена логика.' (#1) from dev into main
Reviewed-on: #1
Reviewed-by: Никита Бизяев <cap7goo@gmail.com>
2026-07-01 19:07:59 +00:00
6 changed files with 18 additions and 27 deletions

View File

@@ -1,10 +1,8 @@
PORT=3101 PORT=3101
branch=
DATABASE_URL=postgres://greact:pG3526l4@194.36.208.86:5433/cloud DATABASE_URL=postgres://greact:pG3526l4@194.36.208.86:5433/cloud
CORS_ALLOWED_ORIGINS=http://localhost:3000,http://localhost:5173
# Optional. When set, POST /ingest requires x-api-key: <value>. # Optional. When set, POST /api/ingest requires x-api-key: <value>.
INGEST_API_KEY= INGEST_API_KEY=
# Poll interval for GET /current/events SSE snapshots. # Poll interval for GET /api/current/events SSE snapshots.
CURRENT_EVENTS_POLL_MS=1000 CURRENT_EVENTS_POLL_MS=1000

View File

@@ -1,5 +1,4 @@
PORT=3101 PORT=3101
DATABASE_URL=postgres://greact:pG3526l4@194.36.208.86:5433/cloud DATABASE_URL=postgres://greact:pG3526l4@194.36.208.86:5433/cloud
CORS_ALLOWED_ORIGINS=http://localhost:3000,http://localhost:5173
INGEST_API_KEY= INGEST_API_KEY=
CURRENT_EVENTS_POLL_MS=1000 CURRENT_EVENTS_POLL_MS=1000

View File

@@ -28,15 +28,17 @@ Historical chart ranges use continuous aggregates:
## API ## API
- `GET /health` All routes are served under the `/api` prefix.
- `GET /edge`
- `GET /tag?edge=edge5&search=pressure`
- `GET /current?edge=edge5&tags=tag1,tag2`
- `GET /history?edge=edge5&tags=tag1,tag2&from=2026-06-01T00:00:00Z&to=2026-06-02T00:00:00Z`
- `POST /ingest`
- `POST /ingest/:edge`
`POST /ingest` accepts one point: - `GET /api/health`
- `GET /api/edge`
- `GET /api/tag?edge=edge5&search=pressure`
- `GET /api/current?edge=edge5&tags=tag1,tag2`
- `GET /api/history?edge=edge5&tags=tag1,tag2&from=2026-06-01T00:00:00Z&to=2026-06-02T00:00:00Z`
- `POST /api/ingest`
- `POST /api/ingest/:edge`
`POST /api/ingest` accepts one point:
```json ```json
{ {
@@ -47,7 +49,7 @@ Historical chart ranges use continuous aggregates:
} }
``` ```
`POST /ingest/:edge` accepts a compact edge payload: `POST /api/ingest/:edge` accepts a compact edge payload:
```json ```json
{ {

View File

@@ -1,13 +1,11 @@
services: services:
drill-cloud-v3: drill-cloud-v3:
container_name: drill-cloud-v3${branch:+-${branch}}
build: . build: .
restart: unless-stopped restart: unless-stopped
environment: environment:
NODE_ENV: production NODE_ENV: production
PORT: ${PORT} PORT: ${PORT}
DATABASE_URL: ${DATABASE_URL} DATABASE_URL: ${DATABASE_URL}
CORS_ALLOWED_ORIGINS: ${CORS_ALLOWED_ORIGINS}
INGEST_API_KEY: ${INGEST_API_KEY} INGEST_API_KEY: ${INGEST_API_KEY}
CURRENT_EVENTS_POLL_MS: ${CURRENT_EVENTS_POLL_MS} CURRENT_EVENTS_POLL_MS: ${CURRENT_EVENTS_POLL_MS}
expose: expose:

View File

@@ -9,15 +9,16 @@ import { IngestService } from './ingest.service';
export class IngestController { export class IngestController {
constructor(private readonly ingest: IngestService) {} constructor(private readonly ingest: IngestService) {}
/** Принимает одну сырую точку и сохраняет ее как запись истории/current. */
@Post() @Post()
ingestPoint(@Body() point: IngestPointDto) { ingestPoint(@Body() point: IngestPointDto) {
return this.ingest.ingestPoint(point); return this.ingest.ingestPoint(point);
} }
/** Принимает компактное тело запроса по edge и сохраняет каждое значение построчно. */
@Post(':edge') @Post(':edge')
ingestEdgeValues(@Param('edge') edge: string, @Body() body: IngestEdgeValuesDto) { ingestEdgeValues(
@Param('edge') edge: string,
@Body() body: IngestEdgeValuesDto,
) {
const points = Object.entries(body.values).map(([tag, value]) => ({ const points = Object.entries(body.values).map(([tag, value]) => ({
edge, edge,
tag, tag,

View File

@@ -3,17 +3,10 @@ import { NestFactory } from '@nestjs/core';
import compression from 'compression'; import compression from 'compression';
import { AppModule } from './app.module'; import { AppModule } from './app.module';
/** Запускает HTTP API со сжатием, CORS и глобальной валидацией DTO. */
async function bootstrap() { async function bootstrap() {
const app = await NestFactory.create(AppModule); const app = await NestFactory.create(AppModule);
app.use(compression()); app.use(compression());
app.setGlobalPrefix('api');
app.enableCors({
origin: process.env.CORS_ALLOWED_ORIGINS,
credentials: true,
methods: ['GET', 'POST', 'PUT', 'PATCH', 'DELETE', 'OPTIONS'],
allowedHeaders: ['Content-Type', 'Authorization', 'x-api-key'],
});
app.useGlobalPipes( app.useGlobalPipes(
new ValidationPipe({ new ValidationPipe({