-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
42 lines (32 loc) · 1.02 KB
/
Copy pathindex.js
File metadata and controls
42 lines (32 loc) · 1.02 KB
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
32
33
34
35
36
37
38
39
40
41
const express = require('express');
const path = require('path');
const bodyParser = require('body-parser');
const morgan = require('morgan');
const mongoose = require('mongoose');
const router = require('./router');
const app = express();
const DBHOST = process.env.DBHOST || 'localhost';
const PORT = process.env.PORT || 5000;
setTimeout(() => {
mongoose.connect(`mongodb://${DBHOST}/digitaldata`);
app.use(morgan('combined'));
app.use(bodyParser.json());
app.use('/', express.static(path.join( __dirname, 'client', 'build' )));
app.use('/admin', express.static(path.join( __dirname, 'client', 'build' )));
router(app);
app.listen(PORT);
console.log(`Server running on port ${PORT}`);
const User = require('./models/user');
setTimeout(() => {
const user = new User({
email: 'mail@mail.com',
password: 'test123',
firstName: 'Damian',
lastName: 'Stolarek',
});
user.save(err => {
console.log(err);
console.log('User saved');
});
}, 8000);
}, 4000);