-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
67 lines (58 loc) · 1.48 KB
/
index.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
63
64
65
66
67
var express = require("express");
var app = express();
var bodyParser = require("body-parser");
var mongoose = require("mongoose");
var xmlparser = require("express-xml-bodyparser")
mongoose.connect("mongodb://localhost:/dudco", (err) => {
if(err){
console.log("db connected error");
throw err;
}
});
app.use(bodyParser.urlencoded({
extended: false
}));
app.use(xmlparser())
var UserSchema = new mongoose.Schema({
_id: String,
email: String,
pw: String,
name: String,
accessToken: String,
token: String,
money: String,
history: Array
});
Users = mongoose.model('users', UserSchema);
LocData = mongoose.model('location', new mongoose.Schema({
title : String,
address : String,
roadAddress : String,
longitude : String,
latitude : String
}), 'locations')
var PORT = 6974;
app.get("/", (req, res)=>{
res.send("hello");
});
app.get("/search/user", (req, res)=>{
var userList = []
Users.find({}, (err, users)=>{
for(user of users){
if(user.name.includes(req.query.name)){
userList.push(user)
}
}
res.send(200, userList)
})
})
app.post("/lora/get", (req, res)=>{
console.log(req.body['m2m:cin'].con[0])
})
app.listen(PORT, ()=>{
console.log("server running at " + PORT + " port");
})
require("./routes/auth")(app, Users);
require("./routes/location")(app, LocData);
require("./routes/self")(app, Users);
require("./routes/money")(app, Users);