cloud creation

This commit is contained in:
Первов Артем
2026-06-17 09:36:58 +03:00
commit 123bd97018
46 changed files with 12285 additions and 0 deletions

112
LOCAL_NO_DOCKER.md Normal file
View File

@@ -0,0 +1,112 @@
# Local Run Without Docker
You can run the API without Docker. The application only needs Node.js and a PostgreSQL database with the TimescaleDB extension installed.
## Requirements
- Node.js 22+
- PostgreSQL 17 or 18
- TimescaleDB extension installed into that PostgreSQL instance
- `psql` available in your terminal
Official TimescaleDB docs for Windows describe installing PostgreSQL, running the TimescaleDB installer, restarting the PostgreSQL service, and enabling the extension with:
```sql
CREATE EXTENSION IF NOT EXISTS timescaledb;
```
Docs: https://docs.tigerdata.com/self-hosted/latest/install/installation-windows/
## 1. Create local database
Open PowerShell and run:
```powershell
createdb -h localhost -p 5432 -U postgres drill_cloud_v2
```
If `createdb` is not in PATH, add your PostgreSQL bin directory, for example:
```powershell
$env:Path += ";C:\Program Files\PostgreSQL\17\bin"
```
## 2. Enable TimescaleDB
```powershell
psql -h localhost -p 5432 -U postgres -d drill_cloud_v2 -c "CREATE EXTENSION IF NOT EXISTS timescaledb;"
```
Check it:
```powershell
psql -h localhost -p 5432 -U postgres -d drill_cloud_v2 -c "\dx"
```
You should see `timescaledb` in the extension list.
## 3. Configure app env
```powershell
Copy-Item .env.local.example .env
```
Edit `.env` if your local PostgreSQL password, port, or database name differs:
```text
DATABASE_URL=postgres://postgres:postgres@localhost:5432/drill_cloud_v2
```
## 4. Install and migrate
```powershell
npm install
npm run migrate
```
## 5. Start API
```powershell
npm run start:dev
```
The API starts on:
```text
http://localhost:3100
```
Health check:
```powershell
Invoke-RestMethod http://localhost:3100/health
```
## Useful local checks
Send one point:
```powershell
Invoke-RestMethod `
-Method Post `
-Uri http://localhost:3100/ingest `
-Headers @{ "x-api-key" = "dev-local-key" } `
-ContentType "application/json" `
-Body '[{"edge":"roman","tag":"test_tag","time":"2026-06-15T12:00:00Z","value":42}]'
```
Read current:
```powershell
Invoke-RestMethod "http://localhost:3100/current?edge=roman"
```
Read chart data:
```powershell
Invoke-RestMethod "http://localhost:3100/history?edge=roman&tags=test_tag&from=2026-06-15T00:00:00Z&to=2026-06-16T00:00:00Z"
```
## Note
The old remote database you gave me does not currently have TimescaleDB enabled. To run this v2 schema there, an admin user must install/allowlist TimescaleDB and run the migrations.