-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
62 lines (57 loc) · 1.45 KB
/
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
var express = require('express');
var bodyParser = require('body-parser');
var api = require('./routes/api');
var mongoose = require('mongoose');
mongoose.connect('mongodb://localhost/test');
var db = mongoose.connection;
db.on('error', function (err) {
console.log('Mongo connection error. Please check Mongo is running on the host');
console.log(err);
});
db.once('open', function () {
console.log('MongoDb connected.');
});
var app = express();
app.listen(3000);
app.use(express.static('public'));
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({extended:false}));
app.use('/api',api);
/**
* Created by Li on 2017/1/16.
* Code to run Mongod on Windows
* open cmd first, and copy those code
* In default db location
*
*================================================
* "C:\Program Files\MongoDB\Server\3.6\bin\mongod.exe"
*
* Start code for Alex
* cd C:\Users\phant\Documents\GitHub\REPL
* node app.js
* cd C:\Users\phant\Documents\GitHub\REPL\Tests
* mocha
*
* Start code for
*
*
*
*
*
*
*
*================================================
*
* On Linux ubuntu start code is
*
* ===============================================
*sudo service mongod start
*================================================
*
*
*stop code is
*================================================
*sudo service mongod stop
*================================================
*
*/