33 lines
781 B
TypeScript
33 lines
781 B
TypeScript
import "dotenv/config";
|
|
import express from "express";
|
|
import { createServer } from "node:http";
|
|
import databaseInit from "./database/init";
|
|
import gateway from "./gateway";
|
|
import server from "./server";
|
|
|
|
const port = process.env.PORT || 3000;
|
|
|
|
const app = express();
|
|
server(app);
|
|
const httpServer = createServer(app);
|
|
gateway(httpServer);
|
|
|
|
|
|
function serve() {
|
|
httpServer.listen(port, () => console.log(`listening on port ${port}`));
|
|
}
|
|
|
|
async function main() {
|
|
if (process.argv[2] === "db-init") {
|
|
console.log("db-init: initializing database...");
|
|
await databaseInit();
|
|
console.log("db-init: databaseInit() finished");
|
|
console.log("database initialized, exiting...");
|
|
process.exit(0);
|
|
return;
|
|
}
|
|
|
|
serve();
|
|
}
|
|
|
|
main();
|