forked from bricewilson/Async-Patterns-in-Node.js
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserver.js
28 lines (20 loc) · 793 Bytes
/
server.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
const express = require('express');
const path = require('path');
const favicon = require('serve-favicon');
const bodyParser = require('body-parser');
const clothing = require('./server/routes/clothing');
const errors = require('./server/routes/errors');
const app = express();
app.use(favicon(path.join(__dirname, 'dist/favicon.ico')));
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: false }));
app.use(express.static(path.join(__dirname, 'dist')));
app.use('/api/clothing', clothing);
app.use('/api/errors', errors);
app.get('*', function(req, res) {
res.sendFile(path.join(__dirname, 'dist/index.html'));
});
app.set('port', process.env.PORT || 3000);
app.listen(app.get('port'));
console.log('Listening on port: ' + app.get('port'));
module.exports = app;