-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.js
More file actions
26 lines (22 loc) · 721 Bytes
/
Copy pathserver.js
File metadata and controls
26 lines (22 loc) · 721 Bytes
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
const express = require('express');
const bodyParser = require('body-parser');
const cors = require('cors');
const path = require('path');
const app = express();
app.use(express.static(__dirname + '/dist'));
app.use(bodyParser.urlencoded({ extended: true }));
app.use(cors());
require('./routes')(app);
app.all('*', (req, res, next) => {
if (req.url === '/') return res.sendFile(path.join(__dirname + '/dist/index.html'));
return res.status(404).send({
code: 404,
error: {
type: "invalid_request_error",
message: `Unable to resolve the request "http://localhost:8081${req.url}"`
}
});
});
app.listen(8080, () => {
console.log('Twitter-app listening on port 8080!');
});