-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
43 lines (35 loc) · 1014 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
32
33
34
35
36
37
38
39
40
41
42
43
'use strict';
const express = require('express');
const path = require('path');
const bodyParser = require('body-parser');
const morgan = require('morgan');
const PORT = process.env.PORT || 4000;
const app = express();
const {
getProjects,
getTestimonials,
} = require('./server/handlers/index');
app
.use(function(req, res, next) {
res.header(
'Access-Control-Allow-Methods',
'OPTIONS, HEAD, GET, PUT, POST, DELETE'
);
res.header(
'Access-Control-Allow-Headers',
'Origin, X-Requested-With, Content-Type, Accept'
);
next();
})
.use(morgan('tiny'))
.use(bodyParser.json())
.use(express.urlencoded({ extended: false }))
.use('/', express.static(__dirname + '/'))
.use(express.static(__dirname))
.use(express.static(path.join(__dirname, 'build')))
.get('/projects', getProjects)
.get('/testimonials', getTestimonials)
.get('/*', function (req, res) {
res.sendFile(path.join(__dirname, 'build', 'index.html'));
})
.listen(PORT, () => console.info(`Listening on port ${PORT}`));