ЛР 2 — БПИ2303 — Морару — на 5 (трек 2)

TypeScript/Node API на PostgreSQL с сессиями в Valkey (AOF), миграции,
compose-стенд, restart hook, тесты уровня 4 и эксперимент трека 2
(планы запроса на 240k сообщений, стоимость записи, backup/restore).
This commit is contained in:
celis
2026-10-29 20:58:56 +03:00
parent 65003b6119
commit cac37bddec
29 changed files with 2229 additions and 18 deletions
+20
View File
@@ -0,0 +1,20 @@
#!/bin/sh
# Generates local synthetic credentials in ./secrets (git-ignored). Safe to re-run: keeps existing files.
set -eu
cd "$(dirname "$0")/.."
mkdir -p secrets
umask 077
rand() { python3 -c 'import secrets; print(secrets.token_urlsafe(24))'; }
if [ ! -f secrets/postgres_password ]; then
pg=$(rand)
printf '%s' "$pg" > secrets/postgres_password
printf 'postgresql://messenger:%s@postgres:5432/messenger' "$pg" > secrets/database_url
fi
if [ ! -f secrets/valkey_auth.conf ]; then
vk=$(rand)
printf 'requirepass %s\n' "$vk" > secrets/valkey_auth.conf
printf 'redis://:%s@valkey:6379/0' "$vk" > secrets/cache_url
fi
# containers run as non-root users and read these via bind-mounted secrets
chmod 644 secrets/*
echo "secrets ready in ./secrets (values not printed)"
+7
View File
@@ -0,0 +1,7 @@
#!/bin/sh
# Full restart of API and every state store (PostgreSQL, Valkey) keeping named volumes.
# Never down -v / flush / re-seed.
set -eu
cd "$(dirname "$0")/.."
docker compose stop api valkey postgres
docker compose start postgres valkey api