waffle/src/index.ts

29 lines
639 B
TypeScript
Raw Normal View History

2022-04-05 22:34:06 +03:00
import "dotenv/config";
2022-04-04 16:50:52 +03:00
import express from "express";
2022-04-05 22:34:06 +03:00
import databaseInit from "./database/init";
import server from "./server";
const port = process.env.PORT || 3000;
2022-04-04 16:50:52 +03:00
const app = express();
2022-04-05 22:34:06 +03:00
server(app);
function serve() {
app.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;
}
2022-04-04 16:50:52 +03:00
2022-04-05 22:34:06 +03:00
serve();
}
2022-04-04 16:50:52 +03:00
2022-04-05 22:34:06 +03:00
main();