-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.js
More file actions
126 lines (113 loc) · 3.68 KB
/
app.js
File metadata and controls
126 lines (113 loc) · 3.68 KB
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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
const express = require('express');
const logger = require('morgan');
const bodyParser = require('body-parser');
const path = require('path');
const Sequelize = require('sequelize');
const sequelize = new Sequelize('hb-showcase', 'leahbelle', null, {
host: 'localhost',
dialect: 'postgres'
});
// const sequelize = new Sequelize('postgres://user:leahbelle:5432/hb-showcase')
// Set up the express app
const app = express();
// Log requests to the console.
app.use(logger('dev'));
// Parse incoming requests data (https://github.com/expressjs/body-parser)
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: false }));
app.use(express.static(path.join(__dirname, 'static')));
// Setup a default catch-all route that sends back a welcome message in JSON format.
app.get('/', (req, res) => res.status(200).send({
message: 'Welcome to the beginning of nothingness.',
}));
app.get('/testing', (req, res) => {
res.sendFile(path.join(__dirname + '/static/templates/base.html'))
});
app.get('/db_connection_testing', (req, res) => {
res.status(200).send(
sequelize
.authenticate()
.then(() => {
console.log('Connected to DB.')
})
.catch(err => {
console.error('Unable to connect to DB.', err)
})
)
});
app.get('/get_card_info', (req, res) => {
var users = sequelize.Userss.findAll({
attributes: ['firstName', 'lastName', 'github', 'linkedIn'],
where: {
id: [1,2]
}
});
console.log(users)
}
// res.status(200).send({
// users: users
// })
);
app.get('/get-card-json', (req, res) => res.status(200).send({
users: [
{
firstName: 'Isabelle',
lastName: 'Miller',
github: 'sloloris',
linkedIn: 'https://www.linkedin.com/in/isabelle-miller/'
},
{
firstName: 'Leah',
lastName: 'Yukelson',
github: 'leahyukelson',
linkedIn: 'https://www.linkedin.com/in/leahyukelson/'
},
],
projects: [
{
projectGithub: 'https://github.com/sloloris/hb-final-project',
title: 'FriendKeeper',
description: 'The email-automating web application for those of us who struggle to keep in touch with the people who matter!',
userId: 1
},
{
projectGithub: 'https://github.com/leahyukelson/Night-Out',
title: 'Night Out',
description: 'A web application that allows a user to plan a night around a pre-planned event by combining the event with nearby restaurant or bar options using the Yelp API and sends an email itinerary to friends with SendGrid API.',
userId: 2
},
],
}));
app.get('/get-users-json', (req, res) => res.status(200).send({
users: [
{
firstName: 'Isabelle',
lastName: 'Miller',
github: 'sloloris',
linkedIn: 'https://www.linkedin.com/in/isabelle-miller/'
},
{
firstName: 'Leah',
lastName: 'Yukelson',
github: 'leahyukelson',
linkedIn: 'https://www.linkedin.com/in/leahyukelson/'
},
]
}));
app.get('/get-projects-json', (req, res) => res.status(200).send({
projects: [
{
projectGithub: 'https://github.com/sloloris/hb-final-project',
title: 'FriendKeeper',
description: 'The email-automating web application for those of us who struggle to keep in touch with the people who matter!',
userId: 1
},
{
projectGithub: 'https://github.com/leahyukelson/Night-Out',
title: 'Night Out',
description: 'A web application that allows a user to plan a night around a pre-planned event by combining the event with nearby restaurant or bar options using the Yelp API and sends an email itinerary to friends with SendGrid API.',
userId: 2
},
]
}));
module.exports = app;