-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathapp.js
More file actions
76 lines (41 loc) · 1.46 KB
/
app.js
File metadata and controls
76 lines (41 loc) · 1.46 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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
var express = require('express'),
mongoose = require('mongoose'),
path = require('path'),
bodyParser = require('body-parser');
var MongoClient = require('mongodb').MongoClient;
var dbins;
MongoClient.connect("mongodb://test:tester123@ds123050.mlab.com:23050/projectone", function (err, db) {
if(err){
console.log('error while connecting to mongo db:::'+err);
}else{
dbins = db;
console.log('we are connected:::::'+dbins);
}
});
//var db = mongoose.connect(' ');
//console.log(db);
var Project = require('./models/projectModel');
var User = require('./models/userModel');
var app = express();
app.use(bodyParser.json());
var port = process.env.PORT || 3000;
var projectfyRouter = express.Router();
projectfyRouter.route('/users').get(function(req,res){
console.log('call from angular:::'+req.body);
var coll = dbins.collection('users', function(err, collection) {});
coll.find().toArray(function(err, items) {
res.json(items);
});
})
function getUsers(){
}
app.use(express.static('public'));
app.use(express.static('node_modules'));
app.use('/api',projectfyRouter);
app.get('/', function(req,res){
console.log("sendiing html for the path /");
res.sendFile(path.join(__dirname + '/index.html'));
});
app.listen(port, function(err){
console.log("running server on from gulp port:::::::"+port);
});