-
Notifications
You must be signed in to change notification settings - Fork 2
/
index.js
30 lines (25 loc) · 882 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
const express = require('express');
const bodyParser = require('body-parser');
const path = require('path');
require('dotenv').config();
const mainRoutes = require('./routes/main');
const creatorRoutes = require('./routes/creator');
const app = express();
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: false }));
app.use(express.static(path.join(__dirname, 'client', 'build')));
app.use((req, res, next) => {
res.setHeader('Access-Control-Allow-Origin', '*');
res.setHeader('Access-Control-Allow-Methods', 'GET,POST,PUT,PATCH,DELETE');
res.setHeader(
'Access-Control-Allow-Headers',
'Content-Type, Authorization',
);
next();
});
app.use(mainRoutes);
app.use('/api', creatorRoutes);
const port = process.env.PORT || 8080;
app.listen(port, () => {
console.log(`synthetic-scripting: listening on port ${port}`);
});