summaryrefslogtreecommitdiff
path: root/src/start.ts
blob: fcdfaea70c3dfe31a1981dc0c0265fa84ffd8674 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
import mongoose from "mongoose";
import { getConfig } from "./lib/config.js";
import app from "./app.js";

const config = getConfig();

mongoose.connect(config.database.mongodb_url, {
  useNewUrlParser: true,
  useUnifiedTopology: true,
});
mongoose.set("useCreateIndex", true);
mongoose.Promise = global.Promise;
mongoose.connection
  .on("connected", () => {
    console.log("Mongoose connection open!");
  })
  .on("error", (err: any) => {
    console.log(`Connection error: ${err.message}`);
  });

const server = app.listen(config.general.port, () => {
  console.log(
    `Welcome to gathio! The app is now running on http://localhost:${config.general.port}`
  );
});