-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
30 lines (23 loc) · 816 Bytes
/
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
const express = require('express');
const app = express();
// required for template engine
var exphbs = require('express-handlebars');
// connect to mongodb using a connector file
require('./mongoconnector');
// Enable Cross-Origin Resource Sharing (CORS)
const cors = require('cors');
app.use(cors());
/*
Declare a port variable to either be read from
an environment variable or declared explicitly
*/
const port = process.env.PORT || 3000;
// use routes from an external file
const mpesaRoutes = require('./routes/mpesaRoutes');
app.use('/', mpesaRoutes)
// Define a templating engine to use for documentation
// will be served at root '/'
app.engine('handlebars', exphbs());
app.set('view engine', 'handlebars');
// start the server
app.listen(port, console.log(`mpesa app listening on port ${port}`));