2024-04-29 21:26:04 +02:00
|
|
|
import http from "http";
|
|
|
|
import { app } from "./app";
|
|
|
|
import env from "./config/environment";
|
2024-05-01 23:24:03 +02:00
|
|
|
import mongoose from 'mongoose' // TODO: dopsat nork module pro db
|
2024-04-29 21:26:04 +02:00
|
|
|
import { Log } from "nork";
|
2024-05-01 23:24:03 +02:00
|
|
|
|
2024-04-29 21:26:04 +02:00
|
|
|
const port: number = env.APP_PORT || 8080;
|
|
|
|
const hostname: string = env.APP_HOSTNAME || "localhost";
|
2024-05-01 23:24:03 +02:00
|
|
|
|
2024-04-29 21:26:04 +02:00
|
|
|
export const server = http.createServer(app);
|
|
|
|
|
|
|
|
// Server
|
2024-05-01 23:24:03 +02:00
|
|
|
//export function runServer(): void {
|
|
|
|
// server.listen(port, hostname, () => {
|
|
|
|
// Log.info(200, `Server is listening on http://${hostname}:${port}`);
|
|
|
|
// });
|
|
|
|
//}
|
|
|
|
//
|
|
|
|
////if (!env.NORK.database) {
|
|
|
|
//runServer();
|
2024-04-29 21:26:04 +02:00
|
|
|
//} else {
|
|
|
|
// const db_connection = database()
|
|
|
|
// runServer()
|
|
|
|
//}
|
2024-05-01 23:24:03 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
(async () => {
|
|
|
|
if (!process.env.DOCS_GEN) {
|
|
|
|
try {
|
|
|
|
await mongoose.connect(env.DB_URI);
|
|
|
|
Log.info(200, 'connected to db');
|
|
|
|
server.listen(port, () => {
|
|
|
|
Log.info(200, `Server is listening on http://localhost:${port}`);
|
|
|
|
});
|
|
|
|
} catch (err: any) {
|
|
|
|
Log.error(500, err);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
})();
|