feat: M0 monorepo skeleton with services, clients, deploy and CI
ci / contract (сгенерированный код совпадает с openapi.yaml) (push) Successful in 3m55s
ci / api (push) Successful in 51s
ci / mobile (Metro-бандл Android) (push) Canceled after 0s
release / images (services/api/Dockerfile, storage-agent, storage-agent) (push) Canceled after 0s
release / images (services/recommender/Dockerfile, recommender, ) (push) Canceled after 0s
ci / recommender (push) Successful in 1m11s
ci / ts (packages + web) (push) Canceled after 3s
release / verify (push) Successful in 1m16s
release / images (apps/web/Dockerfile, web, ) (push) Failing after 2m40s
release / android + release (push) Skipped
release / images (services/api/Dockerfile, api, api) (push) Canceled after 1s

- api/openapi.yaml: contract with /healthz, /readyz, /api/v1/server-info
- services/api (Go): api with oapi-codegen strict server, goose migrations,
  readiness checks for Postgres/Redis; storage-agent stub with internal token
- services/recommender (Python, uv): FastAPI health/readiness/internal status,
  `pipu-rec serve` and `pipu-rec analyze` entrypoints
- packages: generated api-client, core (server URL + server check),
  i18n (ru/en + dictionary check), design-tokens (CSS vars + TS from tokens.json)
- apps/web: Vite + React shell showing server status, language switch
- apps/mobile: Expo (SDK 53) Android app with server connect screen
- deploy: Dockerfiles, compose (prod + dev), nginx template, install/update scripts
- .gitea/workflows: ci.yml and tag-based release.yml (images, signed APK, release)
- scripts/version.mjs: version and Android versionCode from git tag
- tests/fixtures/music/generate.sh: synthetic test library via ffmpeg
- docs: versionCode formula, OpenAPI 3.0.3, dev instructions in README

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
mrleo1nidandClaude Opus 5.5 committed 2026-10-19 23:55:11 +03:00
1 parent 9eb1c25147
commit ebf296542c
98 files changed
+12130 -4

No files matched your search

+17
View File
@@ -0,0 +1,17 @@
{
"name": "@pipu/core",
"version": "0.0.0",
"private": true,
"type": "module",
"exports": { ".": "./src/index.ts" },
"scripts": {
"typecheck": "tsc --noEmit",
"test": "vitest run"
},
"dependencies": {
"@pipu/api-client": "workspace:*"
},
"devDependencies": {
"vitest": "^3.2.4"
}
}
+1
View File
@@ -0,0 +1 @@
export { checkServer, normalizeServerUrl, type ServerCheck } from './server';
+59
View File
@@ -0,0 +1,59 @@
import { createApiClient } from '@pipu/api-client';
import { describe, expect, it } from 'vitest';
import { checkServer, normalizeServerUrl } from './server';
describe('normalizeServerUrl', () => {
it.each([
['music.home.lan', 'https://music.home.lan'],
[' https://music.home.lan/ ', 'https://music.home.lan'],
['http://192.168.1.10:8080', 'http://192.168.1.10:8080'],
['https://home.lan/pipu//', 'https://home.lan/pipu'],
])('%s → %s', (input, expected) => {
expect(normalizeServerUrl(input)).toBe(expected);
});
it.each(['', ' ', 'ftp://music.home.lan', 'https://'])('rejects %j', (input) => {
expect(normalizeServerUrl(input)).toBeNull();
});
});
const info = {
name: 'pipu-music',
version: '0.1.0',
api_version: 'v1',
supported_locales: ['ru', 'en'],
min_android_version_code: 100,
};
function clientReturning(response: () => Response | Promise<Response>) {
return createApiClient({ baseUrl: 'https://music.test', fetch: async () => response() });
}
const json = (body: unknown, status = 200) =>
new Response(JSON.stringify(body), { status, headers: { 'Content-Type': 'application/json' } });
describe('checkServer', () => {
it('reports ok for a compatible server', async () => {
await expect(checkServer(clientReturning(() => json(info)), 100)).resolves.toEqual({ status: 'ok', info });
});
it('reports unsupported_app when the app is too old', async () => {
const res = await checkServer(clientReturning(() => json(info)), 99);
expect(res.status).toBe('unsupported_app');
});
it('reports offline on network errors', async () => {
const res = await checkServer(
clientReturning(() => {
throw new TypeError('Failed to fetch');
}),
);
expect(res).toEqual({ status: 'offline', error: 'Failed to fetch' });
});
it('reports offline with the problem code on API errors', async () => {
const res = await checkServer(clientReturning(() => json({ status: 500, code: 'common.internal' }, 500)));
expect(res).toEqual({ status: 'offline', error: 'common.internal' });
});
});
+43
View File
@@ -0,0 +1,43 @@
import type { ApiClient, ServerInfo } from '@pipu/api-client';
/**
* Приводит введённый пользователем адрес сервера к виду `https://host[:port][/path]` без завершающего слеша.
* Без схемы подставляется https. Возвращает null, если адрес некорректен.
*/
export function normalizeServerUrl(input: string): string | null {
const raw = input.trim();
if (!raw) return null;
const withScheme = /^[a-z][a-z0-9+.-]*:\/\//i.test(raw) ? raw : `https://${raw}`;
let url: URL;
try {
url = new URL(withScheme);
} catch {
return null;
}
if (url.protocol !== 'https:' && url.protocol !== 'http:') return null;
if (!url.hostname) return null;
const path = url.pathname.replace(/\/+$/, '');
return `${url.protocol}//${url.host}${path}`;
}
export type ServerCheck =
| { status: 'ok'; info: ServerInfo }
| { status: 'unsupported_app'; info: ServerInfo }
| { status: 'offline'; error: string };
/**
* Проверяет сервер через GET /api/v1/server-info.
* appVersionCode — versionCode Android-клиента; для веба не передаётся.
*/
export async function checkServer(client: ApiClient, appVersionCode?: number): Promise<ServerCheck> {
try {
const { data, error } = await client.GET('/api/v1/server-info');
if (!data) return { status: 'offline', error: error ? error.code : 'unknown' };
if (appVersionCode !== undefined && appVersionCode < data.min_android_version_code) {
return { status: 'unsupported_app', info: data };
}
return { status: 'ok', info: data };
} catch (e) {
return { status: 'offline', error: e instanceof Error ? e.message : String(e) };
}
}
+1
View File
@@ -0,0 +1 @@
{ "extends": "../../tsconfig.base.json", "compilerOptions": { "lib": ["ES2022", "DOM"] }, "include": ["src"] }