-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
39 lines (29 loc) · 1.06 KB
/
index.js
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
28
29
30
31
32
33
34
35
36
37
38
39
require('dotenv').config();
const express = require("express");
const mongoose = require("mongoose");
const https = require('https');
const fs = require('fs');
var cors = require('cors');
const app = express();
mongoose.set('debug', true);
const connString = 'mongodb://'+process.env.MONGO_USER+':'+process.env.MONGO_PASS+'@'+process.env.MONGO_HOST+"/"+process.env.MONGO_DBNAME+"?authMechanism=SCRAM-SHA-1&authSource=admin&w=1";
mongoose.connect(connString, {useNewUrlParser: true, useUnifiedTopology: true});
const db = mongoose.connection;
db.on('error', (error) => console.log("db.on.error: "+error));
db.once('open', () => {
console.log("DB Connected");
});
app.use(cors())
app.use(express.json());
const MainRouter = require("./routes/Main");
app.use("/", MainRouter);
https.createServer({
key: fs.readFileSync('../certs/key.pem'),
cert: fs.readFileSync('../certs/cert.pem'),
passphrase: process.env.CERT_PASSPHRASE
}, app)
.listen(3000);
/*
app.listen(3000, () => {
console.log("Server started on port 3000");
});*/