forked from SDC-Adrastea/Q-A
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
106 lines (91 loc) · 2.73 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
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
const express = require('express');
const axios = require('axios')
const app = express();
const port = process.env.DEV_PORT || 3022;
app.use(express.json());
var dbIndex = require('./db/index.js')
app.get('/qa/questions', function (req, res) {
dbIndex.getQuestions(req.query.product_id).then((data) => { res.send(data) })
.catch(function (error) {
res.send(error);
console.error(error);
})
})
// app.post('/qa/questions', function (req, res) {
// dbIndex.postQuestions(req.body)
// .then((data) => {
// res.send('Created')
// })
// .catch(function (error) {
// res.send(error);
// console.error(error);
// })
// });
// app.put(`/qa/questions/:question_id/helpful`, function (req, res) {
// dbIndex.helpfulQuestion(req.params.question_id)
// .then((data) => {res.end() })
// .catch(function (error) {
// res.send(error);
// console.error(error);
// })
// });
// app.put('/qa/answers/:answerId/helpful', function (req, res) {
// dbIndex.helpfulAnswer(req.params.answerId)
// .then((data) => { res.end() })
// .catch(function (error) {
// res.send(error);
// console.error(error);
// })
// });
// app.get('/setAnswers', function (req, res) {
// dbIndex.setAnswers()
// .then(() => {console.log('finished setting answers') })
// .catch(function (error) {
// console.error(error);
// })
// })
// app.get('/setQuestions', function (req, res) {
// dbIndex.setQuestions()
// .then(() => {console.log('finished setting setQuestions') })
// .catch(function (error) {
// console.error(error);
// })
// })
app.get('/qa/questions/:question_id/answers', function (req, res) {
dbIndex.AnswersGet(req.params.question_id)
.then((data) => {res.send(data) })
.catch(function (error) {
res.send(error);
console.error(error);
})
})
// app.post('/qa/questions/:questionId/answers', function (req, res) {
// dbIndex.postAnswer(req.params.questionId, req.body)
// .then((data) => {
// res.send('Created')
// })
// .catch(function (error) {
// res.send(error);
// console.error(error);
// })
// });
// app.put('/qa/answers/:answerId/report', function (req, res) {
// dbIndex.reportAnswer(req.params.answerId)
// .then((data) => {res.send(data) })
// .catch(function (error) {
// res.send(error);
// console.error(error);
// })
// });
// app.put('/qa/questions/:questionId/report', function (req, res) {
// dbIndex.reportQuestion(req.params.questionId)
// .then((data) => {res.send(data) })
// .catch(function (error) {
// res.send(error);
// console.error(error);
// })
// });
app.listen(port, () => {
console.log(`listening on port ${port}`)
})
module.exports = { app }