style: format server and shared with prettier

A mechanical prettier --write over server/src, server/tests, server/scripts
and shared/src with the workspaces' .prettierrc; nothing but layout and
import order changes, and every file keeps the same set of imports. shared
is formatted throughout and its format baseline is empty. The server
baseline keeps the 35 files that Prettier would grow past their lint:size
limit (they need a split first, which is not a formatting change), and the
generated entity files stay as their generator writes them.
This commit is contained in:
Maurice
2026-10-10 21:23:37 +02:00
parent f4e518b2df
commit 724c88c201
1978 changed files with 78448 additions and 39347 deletions
@@ -4,21 +4,31 @@
* flag, that link validates its body, and that reload maps a re-consent error to 409
* exactly like activate does. The runtime is mocked — this is the HTTP glue only.
*/
import { describe, it, expect, beforeEach, afterEach, vi } from 'vitest';
import { HttpException } from '@nestjs/common';
import { PluginsController } from '../../../src/nest/plugins/plugins.controller';
import { PluginConsentRequired } from '../../../src/nest/plugins/plugin-runtime.service';
import type { RuntimeEnvService } from '../../../src/nest/app-config/runtime-env.service';
import { PluginConsentRequired } from '../../../src/nest/plugins/plugin-runtime.service';
import { PluginsController } from '../../../src/nest/plugins/plugins.controller';
import { HttpException } from '@nestjs/common';
import { describe, it, expect, beforeEach, afterEach, vi } from 'vitest';
// eslint-disable-next-line @typescript-eslint/no-explicit-any
const ctrl = (runtime: any) => new PluginsController({} as never, runtime, {} as never, { isManaged: () => false } as unknown as RuntimeEnvService);
const ctrl = (runtime: any) =>
new PluginsController({} as never, runtime, {} as never, { isManaged: () => false } as unknown as RuntimeEnvService);
// eslint-disable-next-line @typescript-eslint/no-explicit-any
const status = async (p: Promise<any>): Promise<number> =>
p.then(() => -1, (e) => (e instanceof HttpException ? e.getStatus() : 0));
p.then(
() => -1,
(e) => (e instanceof HttpException ? e.getStatus() : 0),
);
describe('PluginsController dev-link endpoints', () => {
beforeEach(() => { process.env.TREK_PLUGINS_ENABLED = 'true'; });
afterEach(() => { delete process.env.TREK_PLUGINS_DEV_LINK; delete process.env.TREK_PLUGINS_ENABLED; });
beforeEach(() => {
process.env.TREK_PLUGINS_ENABLED = 'true';
});
afterEach(() => {
delete process.env.TREK_PLUGINS_DEV_LINK;
delete process.env.TREK_PLUGINS_ENABLED;
});
it('POST /link is 403 unless dev-link is enabled, 400 without a path, and delegates when enabled', async () => {
const runtime = { link: vi.fn(async () => ({ id: 'x', version: '1.0.0', replaced: false })) };
@@ -34,7 +44,11 @@ describe('PluginsController dev-link endpoints', () => {
it('POST /link surfaces a runtime error as 400', async () => {
process.env.TREK_PLUGINS_DEV_LINK = '1';
const runtime = { link: vi.fn(async () => { throw new Error('no build'); }) };
const runtime = {
link: vi.fn(async () => {
throw new Error('no build');
}),
};
expect(await status(ctrl(runtime).link({ path: '/abs' }))).toBe(400);
});
@@ -48,7 +62,9 @@ describe('PluginsController dev-link endpoints', () => {
it('POST /:id/reload maps a re-consent error to 409 and otherwise returns the live status', async () => {
process.env.TREK_PLUGINS_DEV_LINK = '1';
const consent = {
reload: vi.fn(async () => { throw new PluginConsentRequired('needs consent', ['db:read:trips'], []); }),
reload: vi.fn(async () => {
throw new PluginConsentRequired('needs consent', ['db:read:trips'], []);
}),
isActive: () => false,
};
expect(await status(ctrl(consent).reload('p'))).toBe(409);
@@ -56,7 +72,12 @@ describe('PluginsController dev-link endpoints', () => {
const ok = { reload: vi.fn(async () => {}), isActive: () => true };
expect(await ctrl(ok).reload('p')).toEqual({ status: 'active' });
const bad = { reload: vi.fn(async () => { throw new Error('boom'); }), isActive: () => false };
const bad = {
reload: vi.fn(async () => {
throw new Error('boom');
}),
isActive: () => false,
};
expect(await status(ctrl(bad).reload('p'))).toBe(400);
});
});