-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.js
More file actions
31 lines (24 loc) · 683 Bytes
/
app.js
File metadata and controls
31 lines (24 loc) · 683 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
27
28
29
30
31
'use strict'
import path from 'path';
import config from 'config';
import express from 'express';
import bodyParser from 'body-parser';
import mongoose from 'mongoose';
import api from './routes';
mongoose.connect(config.get('mongoUrl'));
const app = express();
const PORT = config.port;
const PUBLIC_DIR = path.join(__dirname, 'public');
app.use(bodyParser.json());
app.use('/api', api);
app.use(express.static(PUBLIC_DIR));
//error handling. Prevents large stack traces in console
app.use((err, req, res, next) => {
res.status(500).json({
error: err.message
});
});
app.listen(PORT, () => {
console.log(`Server listening on port ${PORT}`);
});
export default app;