-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhome.js
71 lines (51 loc) · 1.91 KB
/
home.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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
/* Home.js: the backbone of the web app.
* It listens the app on a local port or through Heroku and helps
* the user navigate through the program.
*/
// These are the modules we will be using.
const mongoose = require('mongoose');
const authRoute = require('./routes/auth');
const bodyParser = require('body-parser');
const express = require('express');
const path = require('path');
/* Mongo DB connection string*/
const url = "mongodb+srv://mhidrovo:aaa@cluster0.jwixh.mongodb.net/Drinks?retryWrites=true&w=majority";
const app = express();
mongoose.connect(url,{ useUnifiedTopology: true, useNewUrlParser: true, useCreateIndex:true }, () =>
console.log("Connected!"));
// Middleware:
app.use(express.json());
// Route middlewares:
app.use("/api/user", authRoute);
/* App redirections when a user clicks on a hyperlink. */
app.get('/about', function(req, res) {
res.sendFile(path.join(__dirname, '/public', 'about2.html'));
console.log('listening')
});
app.get('/invalidLogin', function(req, res) {
res.sendFile(path.join(__dirname, '/public', 'loginError.html'));
console.log('listening')
});
app.get('/registerError', function(req, res) {
res.sendFile(path.join(__dirname, '/public', 'signupError.html'));
console.log('listening')
});
app.get('/index', function(req, res) {
res.sendFile(path.join(__dirname, '/public', 'index.html'));
console.log('listening');
});
app.get('/cocktails', function(req, res) {
res.sendFile(path.join(__dirname, '/public', 'cocktails.html'));
console.log('listening');
});
app.get('/home', function(req, res) {
res.sendFile(path.join(__dirname, '/public', 'home.html'));
console.log('listening');
});
//gets css & pictures & any other static file
app.use(express.static('public'))
const port = process.env.PORT || 4000;
app.use(bodyParser.urlencoded({ extended: true }))
app.listen(port, function() {
console.log('Welcome to our app!');
});