-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
57 lines (49 loc) · 1.54 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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
/* setting up express */
const express = require('express');
const path = require('path');
const logger = require('morgan');
const bodyParser = require('body-parser');
const methodOverride = require('method-override');
const app = express();
/* importing route */
const auctionRoutes = require('./routes/auctions');
/* setting up port & listen */
const PORT = process.env.PORT || 4000;
app.listen(PORT, function() {
console.log(`listening on port ${PORT}`);
});
/* setting up views */
app.set('views', path.join(__dirname, 'views'));
app.set('view engine', 'ejs');
/* setting static file */
app.use('/static', express.static(path.join(__dirname, 'public')));
/* setting up logger */
app.use(logger('dev'));
/* setting up body-parser */
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: false }));
app.use(methodOverride('_method'));
const keyPublishable = process.env.PUBLISHABLE_KEY;
const keySecret = process.env.SECRET_KEY;
const stripe = require("stripe")(keySecret);
const RapidAPI = new require('rapidapi-connect');
const rapid = new RapidAPI('Auction', 'fe12ae8b-57d5-499c-9548-dc9b4c2540d1')
/* setting up routes */
app.get('/', function(req, res){
res.render('index', {
message: 'Welcome!',
documentTitle: 'Auction App',
subTitle: 'Selling your old stuff here',
auctionItems: [
'jeans',
'playstation 4 pro',
'legos',
'honda civic',
],
});
});
app.use('/auctions', auctionRoutes);
/* handling 404 */
app.get('*', function(req, res) {
res.status(404).send({message: 'Oops! Not Found.' });
});