bc-explorer/start.js

32 lines
925 B
JavaScript

// @ts-check
const HeatSync = require("heatsync")
const sqlite = require("better-sqlite3")
const {createServer} = require("http")
const h3 = require("h3")
const {createApp, createRouter, toNodeListener} = require("h3")
const passthrough = require("./passthrough")
const sync = new HeatSync()
sync.events.on("error", console.error)
passthrough.db = new sqlite("bc-explorer.db")
const app = createApp()
const router = createRouter()
app.use(router)
require("./db/migrate").migrate(passthrough.db)
const {from, select} = sync.require("./db/orm")
Object.assign(passthrough, {sync, router, from, select})
/** @type {import("./pug-sync")} */
const pugSync = sync.require("./pug-sync")
/** @type {import("./icons")} */
const icons = sync.require("./icons")
pugSync.addGlobals({h3, select, icons})
sync.require("./routes/_index")
createServer(toNodeListener(app)).listen(2239)
console.log("running on http://localhost:2239")