-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
33 lines (25 loc) · 873 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
31
32
33
//create the server
const express = require("express");
const app = express();
const path = require('path');
var cors = require('cors');
var bodyParser = require("body-parser");
const port = process.env.PORT | 3000;
app.use(bodyParser.urlencoded({
extended: true
}));
app.use(bodyParser.json());
const payments = require('./Routes/payments');
app.use(cors());
app.use('/payments', payments);
app.use((req, res, next) => {
res.header('Access-Control-Allow-Origin', '*');
res.header('Access-Control-Allow-Headers', 'Origin, X-Requested-With, Content-Type, Accept');
res.header('Access-Control-Allow-Credentials', true);
res.header('Access-Control-Allow-Methods', 'GET, POST, PUT, PATCH');
next();
});
app.use(express.static(path.join(__dirname, 'public')));
app.listen(port, () => {
console.log(`Server listening at http://*:${port}`);
});