-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
40 lines (30 loc) · 1.01 KB
/
app.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
40
const express = require("express")
const mongoose = require("mongoose")
const dotEnv = require("dotenv")
const routes = require("./routes/appointmentRoutes")
const app = express()
const methodOverride = require('method-override');
dotEnv.config()
//middleware
app.use(methodOverride('_method'));
app.use(express.json());
app.use(express.urlencoded({extended: true}));
app.use(express.static("public"));
app.use("/", routes)
//view engine
app.set("view engine", "ejs")
app.set("views", "render")
// mongoose.connect(process.env.DB_CONNECT, {useNewUrlParser: true, useUnifiedTopology: true}, (err)=>{
// if(err) throw err
// console.log("Connected")
// })
mongoose.connect(process.env.DB_CONNECT , ()=>{
console.log(`Connected to Database. \nPlease check DB_CONNECT to verify connection.`)
})
//connect
// const port = 3000
// app.listen(port, ()=>{
// console.log(`Connected to port: ${port}`)
// })
var port_number = process.env.PORT || 3000;
app.listen(port_number, ()=>console.log(`PORT: ${port_number}`));