SPB Git forge

spb/spinza

Public
8commits 1branches 0releases
1.6 MBsize
maindefault branch
16 days agolast push
TypeScript 97.6% SQL 1.4% JavaScript 0.5%
1.1 KB · 34 lines typescript
Raw Blame History
1import { buildApp } from "./app";2import { config } from "./config";3import { closeDb, getDb } from "@spinza/database";4import { syncGames } from "@spinza/database/sync-games";5import { closeRedis } from "./lib/redis";67async function main() {8  const app = await buildApp();9  // Keep the games table in sync with the shipped library on boot (lifecycle respects certifications).10  try {11    const reports = await syncGames(getDb());12    app.log.info({ published: reports.filter((r) => r.lifecycle === "published").length, total: reports.length }, "game library synced");13  } catch (e) {14    app.log.error({ err: e }, "game sync failed");15  }16  await app.listen({ port: config.port, host: config.host });17  app.log.info(`Spinza API listening on http://${config.host}:${config.port} (${config.env})`);1819  const shutdown = async (signal: string) => {20    app.log.info({ signal }, "shutting down");21    await app.close();22    await closeDb();23    await closeRedis();24    process.exit(0);25  };26  process.on("SIGINT", () => void shutdown("SIGINT"));27  process.on("SIGTERM", () => void shutdown("SIGTERM"));28}2930main().catch((e) => {31  console.error(e);32  process.exit(1);33});34