summaryrefslogtreecommitdiff
path: root/src/start.js
blob: ca178626e0a8553e39baae159c810d437caa5f48 (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
26
27
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) => {
    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:${
      server.address().port
    }`
  );
});