forked from junior-devleague/aws-developer-final
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
54 lines (46 loc) · 1.32 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
const express = require('express');
const app = express();
const PORT = 3000;
const bodyParser = require('body-parser');
const exphbs = require('express-handlebars');
const AWS = require('aws-sdk');
AWS.config.loadFromPath('./config.json')
const sqs = new AWS.SQS({apiVersion: '2012-11-05'});
const path = require('path');
const home = require('./routes/home');
const newOrder = require('./routes/new-order');
const confirmOrder = require('./routes/confirm-order');
// const clientJS = require('./public/client');
app.use(bodyParser.urlencoded({extended:true}))
app.use("/public", express.static(path.join(__dirname, 'public')));
// app.use(express.static('images'))
app.set('view engine', '.hbs');
app.engine('.hbs', exphbs({
extname:'.hbs',
defaultLayout:'main',
}))
app.use('/', home)
app.use('/', newOrder)
app.use('/', confirmOrder)
// app.use('/', clientJS)
// CREATE QUEUE
function createQueue() {
let qParams = {
QueueName: 'surfboard-order-queue',
Attributes: {
'DelaySeconds': '5',
'MessageRetentionPeriod': '86400'
}
};
sqs.createQueue(qParams, (err, data) => {
if (err) {
console.log(`Error in creating queue: ${err}`);
} else {
console.log(`Queue creation succeeded: ${data.QueueUrl}`);
}
});
}
createQueue();
app.listen(PORT, () => {
console.log(`Server started, listening on ${PORT}`);
})