Files
hope-food-pantry-app/tests/signup-race-worker.ts
blake f1a46e2ba7 feat: add volunteer shift signup app
Initial source, tests, migrations, and local Docker setup for the Hope Food Pantry volunteer scheduler.
2026-10-16 09:33:39 -05:00

26 lines
868 B
TypeScript

// Spawned with `node --import tsx`. Those .ts specifiers are intentional.
// tsconfig excludes this file because tsc does not allow that import style.
import { openDatabaseFile } from '../src/db.ts';
import { reserveSignup, type ReserveInput } from '../src/signup.ts';
const data = JSON.parse(process.env.HOPE_RACE ?? '') as { databaseFile: string; input: ReserveInput };
const db = openDatabaseFile(data.databaseFile);
try {
const result = reserveSignup(db, data.input);
process.stdout.write(JSON.stringify({
ok: result.ok,
reason: result.ok ? null : result.reason,
replay: result.ok ? result.replay : false,
}));
} catch (err) {
process.stdout.write(JSON.stringify({
ok: false,
reason: 'error',
replay: false,
message: err instanceof Error ? err.message : String(err),
}));
process.exitCode = 1;
} finally {
db.close();
}