f500db971b
build-and-push / build-and-push (push) Successful in 1m26s
Fastify + node:sqlite single-process app with vanilla JS UI for looking up hosts by hardware ID, hostname, or asset ID. Includes per-host network interface tracking, sites/rooms/server-types CRUD, Docker packaging, and a Gitea Actions workflow that runs tests then builds and pushes to gitea.thewrightserver.net/josh/infrastructure. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
38 lines
1.1 KiB
JavaScript
38 lines
1.1 KiB
JavaScript
import { buildApp } from '../src/server.js';
|
|
|
|
export async function newApp() {
|
|
return buildApp({ dbPath: ':memory:', seed: false });
|
|
}
|
|
|
|
export async function seedFixtures(app) {
|
|
const site = JSON.parse((await app.inject({
|
|
method: 'POST', url: '/api/sites', payload: { name: 'HQ' },
|
|
})).body);
|
|
const room = JSON.parse((await app.inject({
|
|
method: 'POST', url: '/api/rooms', payload: { site_id: site.id, name: 'Main' },
|
|
})).body);
|
|
const type = JSON.parse((await app.inject({
|
|
method: 'POST', url: '/api/server-types', payload: { name: 'Web' },
|
|
})).body);
|
|
return { site, room, type };
|
|
}
|
|
|
|
export function newHostPayload({ room_id, server_type_id }, suffix = '') {
|
|
return {
|
|
hardware_id: `HW-${suffix || '1'}`,
|
|
hostname: `host-${suffix || '1'}`,
|
|
asset_id: `AST-${suffix || '1'}`,
|
|
room_id,
|
|
position: 'R1-U1',
|
|
server_type_id,
|
|
};
|
|
}
|
|
|
|
export async function seedHost(app, fx, suffix = '') {
|
|
const res = await app.inject({
|
|
method: 'POST', url: '/api/hosts',
|
|
payload: newHostPayload({ room_id: fx.room.id, server_type_id: fx.type.id }, suffix),
|
|
});
|
|
return JSON.parse(res.body);
|
|
}
|