-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
32 lines (24 loc) · 797 Bytes
/
app.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 app = express();
const bodyParser = require('body-parser');
const morgan = require('morgan');
const apiRoutes = require('./routes/index.js');
const path = require('path');
const router = require('express').Router();
//morgan middleware
app.use(morgan('dev'));
app.set('port', (process.env.PORT || 3005));
//implementing body-parser
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({extended: true}));
app.use('/api', apiRoutes);
//posting all files in public folder
app.use(express.static('public'));
//all other routes
app.get('/*', function(req, res){
res.sendFile(path.resolve(__dirname, 'browser/index.html'));
})
//listening on port 3005
const server = app.listen(app.get('port'), function(){
console.log('listening on 3005');
})