Showing
1 changed file
with
1 additions
and
55 deletions
1 | let express = require('express'); | 1 | let express = require('express'); |
2 | let bodyParser = require('body-parser'); | 2 | let bodyParser = require('body-parser'); |
3 | let mongoose = require('mongoose'); | 3 | let mongoose = require('mongoose'); |
4 | -<<<<<<< HEAD | ||
5 | 4 | ||
6 | let cors = require('cors'); | 5 | let cors = require('cors'); |
7 | let app = express(); | 6 | let app = express(); |
8 | app.use(cors()); | 7 | app.use(cors()); |
9 | -======= | ||
10 | -let nx,ny; | ||
11 | -let app = express(); | ||
12 | -const cors=require('cors'); | ||
13 | -app.use(cors); | ||
14 | ->>>>>>> origin/weather | ||
15 | 8 | ||
16 | let logid=null; | 9 | let logid=null; |
17 | //const uri = 'mongodb+srv://sjieu17:tjrwls147714@cluster0.lc6pe.mongodb.net/weather_briefing?retryWrites=true&w=majority'; | 10 | //const uri = 'mongodb+srv://sjieu17:tjrwls147714@cluster0.lc6pe.mongodb.net/weather_briefing?retryWrites=true&w=majority'; |
... | @@ -24,19 +17,12 @@ let db = mongoose.connect(uri, (err) => { | ... | @@ -24,19 +17,12 @@ let db = mongoose.connect(uri, (err) => { |
24 | console.log('Succesfully Connected!'); | 17 | console.log('Succesfully Connected!'); |
25 | } | 18 | } |
26 | }); | 19 | }); |
27 | -//생년월일을 인자로 추가 | 20 | + |
28 | var UserSchema = new mongoose.Schema({ | 21 | var UserSchema = new mongoose.Schema({ |
29 | name: String, | 22 | name: String, |
30 | id: String, | 23 | id: String, |
31 | -<<<<<<< HEAD | ||
32 | password: String, | 24 | password: String, |
33 | gender:String | 25 | gender:String |
34 | -======= | ||
35 | - password: String, | ||
36 | - gender:String, | ||
37 | - //nx:String, | ||
38 | - //ny:String | ||
39 | ->>>>>>> origin/weather | ||
40 | }); | 26 | }); |
41 | 27 | ||
42 | var Users = mongoose.model('users', UserSchema); | 28 | var Users = mongoose.model('users', UserSchema); |
... | @@ -45,23 +31,15 @@ app.use(bodyParser.json()); | ... | @@ -45,23 +31,15 @@ app.use(bodyParser.json()); |
45 | app.use(bodyParser.urlencoded({ limit: '1gb', extended: false })); | 31 | app.use(bodyParser.urlencoded({ limit: '1gb', extended: false })); |
46 | 32 | ||
47 | app.post('/api/register', (req, res) => { | 33 | app.post('/api/register', (req, res) => { |
48 | -<<<<<<< HEAD | ||
49 | 34 | ||
50 | Users.findOne({ id: req.body.id, password: req.body.password }, (err, user) => { | 35 | Users.findOne({ id: req.body.id, password: req.body.password }, (err, user) => { |
51 | if (err) return res.status(500).json({ registerSuccess: '-1'}); | 36 | if (err) return res.status(500).json({ registerSuccess: '-1'}); |
52 | else if (user){ | 37 | else if (user){ |
53 | res.json({ registerSuccess: '0'}); | 38 | res.json({ registerSuccess: '0'}); |
54 | -======= | ||
55 | - Users.findOne({ id: req.body.id, password: req.body.password }, (err, user) => { | ||
56 | - if (err) return res.status(500).json({ message: '에러가 발생하였습니다.' }); | ||
57 | - else if (user){ | ||
58 | - res.send('이미 존재하는 사용자입니다.'); | ||
59 | ->>>>>>> origin/weather | ||
60 | } | 39 | } |
61 | else{ | 40 | else{ |
62 | const new_user = new Users(req.body); | 41 | const new_user = new Users(req.body); |
63 | 42 | ||
64 | -<<<<<<< HEAD | ||
65 | new_user.save((err) => { | 43 | new_user.save((err) => { |
66 | if (err) return res.status(500).json({ registerSuccess: '-1'}); | 44 | if (err) return res.status(500).json({ registerSuccess: '-1'}); |
67 | else return res.status(200).json({ registerSuccess: '1'}); | 45 | else return res.status(200).json({ registerSuccess: '1'}); |
... | @@ -78,22 +56,6 @@ app.post('/api/login', (req, res) => { | ... | @@ -78,22 +56,6 @@ app.post('/api/login', (req, res) => { |
78 | else if (user) { | 56 | else if (user) { |
79 | // logid={id:user.id,password:user.password,name:user.name,gender:user.gender}; | 57 | // logid={id:user.id,password:user.password,name:user.name,gender:user.gender}; |
80 | return res.status(200).json({ loginSuccess: true }); | 58 | return res.status(200).json({ loginSuccess: true }); |
81 | -======= | ||
82 | - new_user.save((err) => { | ||
83 | - if (err) return res.status(500).json({ message: '회원가입에 실패하였습니다.', success: false, err }); | ||
84 | - else return res.status(200).json({ message: '회원가입이 완료되었습니다.', success: true }); | ||
85 | - }); | ||
86 | - } | ||
87 | - }); | ||
88 | -}); | ||
89 | - | ||
90 | -app.post('/login', (req, res) => { | ||
91 | - Users.findOne({ id: req.body.id, password: req.body.password }, (err, user) => { | ||
92 | - if (err) return res.status(500).json({ message: '에러가 발생하였습니다.' }); | ||
93 | - else if (user){ | ||
94 | - logid={id:user.id,password:user.password,name:user.name,gender:user.gender,address1:user.address1,address2:user.address2,address3:user.address3}; | ||
95 | - return res.status(200).json({ message: '로그인 되었습니다.', data: user }); | ||
96 | ->>>>>>> origin/weather | ||
97 | } | 59 | } |
98 | else return res.status(404).json({ loginSuccess: false }); | 60 | else return res.status(404).json({ loginSuccess: false }); |
99 | }); | 61 | }); |
... | @@ -103,21 +65,5 @@ app.post('/api/logout',(req,res)=>{ | ... | @@ -103,21 +65,5 @@ app.post('/api/logout',(req,res)=>{ |
103 | logid=null; | 65 | logid=null; |
104 | res.send('로그아웃 되었습니다.'); | 66 | res.send('로그아웃 되었습니다.'); |
105 | }); | 67 | }); |
106 | -<<<<<<< HEAD | ||
107 | 68 | ||
108 | -======= | ||
109 | -// const xlsx=require('xlsx'); | ||
110 | -// const excel=xlsx.readFile('location(x,y).xlsx'); | ||
111 | -// const sheet=excel.SheetNames[0]; | ||
112 | -// const first=excel.Sheets[sheet]; | ||
113 | -// const jsonData=xlsx.utils.sheet_to_json(first,{defval:""}); | ||
114 | -// jsonData.findOne({address1:logid.address1,address2:logid.address2,address3:logid.address3},(err,user)=>{ | ||
115 | -// if (err) return console.log("일치하는 주소가 없습니다."); | ||
116 | -// else if(user){ | ||
117 | -// tmp=Object.values(user); | ||
118 | -// nx=tmp[5]; | ||
119 | -// ny=tmp[6]; | ||
120 | -// } | ||
121 | -// }); | ||
122 | ->>>>>>> origin/weather | ||
123 | app.listen(4000, () => console.log('Server On 4000')); | 69 | app.listen(4000, () => console.log('Server On 4000')); |
... | \ No newline at end of file | ... | \ No newline at end of file | ... | ... |
-
Please register or login to post a comment