NestJS + Prisma/Postgres API shared by the site, admin and attendee app. Ports the site's D1 application flow and review, stores every inquiry form, sells tickets with discount codes (manual payment confirmation), and runs booth/startup/mystery-investee QR scans with derived points and raffles. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
32 lines
981 B
JavaScript
32 lines
981 B
JavaScript
// Local Postgres without Docker: PGlite (real Postgres 17 in WASM) behind the wire protocol.
|
|
// Usage: pnpm db:dev → postgresql://postgres:postgres@127.0.0.1:5433/postgres
|
|
// Use Docker Compose Postgres instead whenever Docker is available.
|
|
import { mkdirSync } from 'node:fs';
|
|
import { PGlite } from '@electric-sql/pglite';
|
|
|
|
import { PGLiteSocketServer } from '@electric-sql/pglite-socket';
|
|
|
|
const dataDir = process.env.PGLITE_DIR ?? '.data/pglite';
|
|
const port = Number(process.env.PGLITE_PORT ?? 5433);
|
|
mkdirSync(dataDir, { recursive: true });
|
|
|
|
const db = await PGlite.create({ dataDir });
|
|
const server = new PGLiteSocketServer({
|
|
db,
|
|
port,
|
|
host: '127.0.0.1',
|
|
maxConnections: 20,
|
|
});
|
|
await server.start();
|
|
console.log(
|
|
`PGlite listening on postgresql://postgres:postgres@127.0.0.1:${port}/postgres (${dataDir})`,
|
|
);
|
|
|
|
const stop = async () => {
|
|
await server.stop();
|
|
await db.close();
|
|
process.exit(0);
|
|
};
|
|
process.on('SIGINT', stop);
|
|
process.on('SIGTERM', stop);
|