forked from darthlukan/tatproxy
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
31 lines (23 loc) · 794 Bytes
/
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
const express = require('express');
const cors = require('cors');
const bodyParser = require('body-parser');
const validator = require('./src/validator');
const Joi = require('@hapi/joi');
const app = express();
const corsOptions = {
origin: true,
optionsSuccessStatus: 200
};
app.use(express.static('www'));
app.use(bodyParser.json());
app.use(cors(corsOptions));
// Enable CORS pre-flight across the board to allow for PATCH/DELETE calls https://www.npmjs.com/package/cors#enabling-cors-pre-flight
app.options('*', cors());
app.set('port', process.env.PORT || 8000);
require('./src/api')(app);
app.post('/ping', function(req, res) {
res.send('pong');
});
app.listen(app.get('port'), function() {
console.log('App started at: %s on port: %s', new Date(), app.get('port'));
});