Showing
7 changed files
with
30 additions
and
7 deletions
... | @@ -3066,6 +3066,14 @@ | ... | @@ -3066,6 +3066,14 @@ |
3066 | "resolved": "https://registry.npmjs.org/axe-core/-/axe-core-4.2.1.tgz", | 3066 | "resolved": "https://registry.npmjs.org/axe-core/-/axe-core-4.2.1.tgz", |
3067 | "integrity": "sha512-evY7DN8qSIbsW2H/TWQ1bX3sXN1d4MNb5Vb4n7BzPuCwRHdkZ1H2eNLuSh73EoQqkGKUtju2G2HCcjCfhvZIAA==" | 3067 | "integrity": "sha512-evY7DN8qSIbsW2H/TWQ1bX3sXN1d4MNb5Vb4n7BzPuCwRHdkZ1H2eNLuSh73EoQqkGKUtju2G2HCcjCfhvZIAA==" |
3068 | }, | 3068 | }, |
3069 | + "axios": { | ||
3070 | + "version": "0.21.1", | ||
3071 | + "resolved": "https://registry.npmjs.org/axios/-/axios-0.21.1.tgz", | ||
3072 | + "integrity": "sha512-dKQiRHxGD9PPRIUNIWvZhPTPpl1rf/OxTYKsqKUDjBwYylTvV7SjSHJb9ratfyzM6wCdLCOYLzs73qpg5c4iGA==", | ||
3073 | + "requires": { | ||
3074 | + "follow-redirects": "^1.10.0" | ||
3075 | + } | ||
3076 | + }, | ||
3069 | "axobject-query": { | 3077 | "axobject-query": { |
3070 | "version": "2.2.0", | 3078 | "version": "2.2.0", |
3071 | "resolved": "https://registry.npmjs.org/axobject-query/-/axobject-query-2.2.0.tgz", | 3079 | "resolved": "https://registry.npmjs.org/axobject-query/-/axobject-query-2.2.0.tgz", | ... | ... |
... | @@ -6,6 +6,7 @@ | ... | @@ -6,6 +6,7 @@ |
6 | "@testing-library/jest-dom": "^5.12.0", | 6 | "@testing-library/jest-dom": "^5.12.0", |
7 | "@testing-library/react": "^11.2.7", | 7 | "@testing-library/react": "^11.2.7", |
8 | "@testing-library/user-event": "^12.8.3", | 8 | "@testing-library/user-event": "^12.8.3", |
9 | + "axios": "^0.21.1", | ||
9 | "react": "^17.0.2", | 10 | "react": "^17.0.2", |
10 | "react-dom": "^17.0.2", | 11 | "react-dom": "^17.0.2", |
11 | "react-router-dom": "^5.2.0", | 12 | "react-router-dom": "^5.2.0", | ... | ... |
1 | -import React from 'react' | 1 | +import React, {useEffect} from 'react' |
2 | +import axios from 'axios' | ||
3 | + | ||
4 | +function LandingPage() { | ||
5 | + // 랜딩페이지에 들어오자마자 | ||
6 | + useEffect(() => { | ||
7 | + axios.get('http://localhost:5000/api/hello') // get request를 서버로 보냄 (endpoint는 /api/hello) | ||
8 | + .then(response => console.log(response.data)) // 서버로부터 응답 받은 내용을 콘솔에 출력 | ||
9 | + }, []) | ||
2 | 10 | ||
3 | -function LandingPage() { | ||
4 | return ( | 11 | return ( |
5 | <div> | 12 | <div> |
6 | LandingPage 랜딩페이지 | 13 | LandingPage 랜딩페이지 | ... | ... |
... | @@ -3,7 +3,8 @@ const app = express() | ... | @@ -3,7 +3,8 @@ const app = express() |
3 | const port = 5000 | 3 | const port = 5000 |
4 | 4 | ||
5 | // User.js에서 만든 model을 가져옴 | 5 | // User.js에서 만든 model을 가져옴 |
6 | -const { User } = require('./server/models/User') | 6 | +const { User } = require('./models/User') |
7 | +//const { User } = require('./') | ||
7 | 8 | ||
8 | // body-parser 가져옴 | 9 | // body-parser 가져옴 |
9 | const bodyParser = require('body-parser') | 10 | const bodyParser = require('body-parser') |
... | @@ -11,14 +12,14 @@ const bodyParser = require('body-parser') | ... | @@ -11,14 +12,14 @@ const bodyParser = require('body-parser') |
11 | app.use(bodyParser.urlencoded({extended: true})) //application/x-www-form-urlencoded로 된 데이터를 분석해서 가져옴 | 12 | app.use(bodyParser.urlencoded({extended: true})) //application/x-www-form-urlencoded로 된 데이터를 분석해서 가져옴 |
12 | app.use(bodyParser.json()) // application/json 타입으로 된 데이터를 분석해서 가져옴 | 13 | app.use(bodyParser.json()) // application/json 타입으로 된 데이터를 분석해서 가져옴 |
13 | 14 | ||
14 | -const config = require('./server/config/key') | 15 | +const config = require('./config/key') |
15 | 16 | ||
16 | const cookieParser = require('cookie-parser') | 17 | const cookieParser = require('cookie-parser') |
17 | app.use(cookieParser()) | 18 | app.use(cookieParser()) |
18 | 19 | ||
19 | const mongoose = require('mongoose') | 20 | const mongoose = require('mongoose') |
20 | 21 | ||
21 | -const { auth } = require('./server/middleware/auth') | 22 | +const { auth } = require('./middleware/auth') |
22 | 23 | ||
23 | //이 정보는 비밀임..! 몽고DB아이디랑 비밀번호를 감춰야해..! | 24 | //이 정보는 비밀임..! 몽고DB아이디랑 비밀번호를 감춰야해..! |
24 | mongoose.connect(config.mongoURI, { | 25 | mongoose.connect(config.mongoURI, { |
... | @@ -107,6 +108,12 @@ app.get('/api/users/logout', auth, (req, res) => { | ... | @@ -107,6 +108,12 @@ app.get('/api/users/logout', auth, (req, res) => { |
107 | }) | 108 | }) |
108 | }) | 109 | }) |
109 | 110 | ||
111 | +// test | ||
112 | +app.get('/api/hello', (req, res) => { | ||
113 | + | ||
114 | + res.send("hello"); | ||
115 | +}) | ||
116 | + | ||
110 | app.listen(port, () => { | 117 | app.listen(port, () => { |
111 | console.log(`Example app listening at http://localhost:${port}`) | 118 | console.log(`Example app listening at http://localhost:${port}`) |
112 | }) | 119 | }) |
... | \ No newline at end of file | ... | \ No newline at end of file | ... | ... |
... | @@ -47,10 +47,10 @@ userSchema.pre('save', function( next ){ | ... | @@ -47,10 +47,10 @@ userSchema.pre('save', function( next ){ |
47 | if(user.isModified('password')) // password를 변경할 때만 적용되도록.. | 47 | if(user.isModified('password')) // password를 변경할 때만 적용되도록.. |
48 | { | 48 | { |
49 | // 비밀번호 암호화 (https://www.npmjs.com/package/bcrypt 에서 가져옴) | 49 | // 비밀번호 암호화 (https://www.npmjs.com/package/bcrypt 에서 가져옴) |
50 | - bcrypt.genSalt(saltRounds, function(err, salt) // salt를 만드는 함수 | 50 | + bcrypt.genSalt(saltRounds, (err, salt) => // salt를 만드는 함수 |
51 | { | 51 | { |
52 | if(err) return next(err) // 에러 나면 return err | 52 | if(err) return next(err) // 에러 나면 return err |
53 | - bcrypt.hash(user.password, salt, function(err, hash) { // bcrypt.hash(암호화되지 않은 pw, salt, function(err, 암호화된 비밀번호)) | 53 | + bcrypt.hash(user.password, salt, (err, hash) => { // bcrypt.hash(암호화되지 않은 pw, salt, function(err, 암호화된 비밀번호)) |
54 | if(err) return next(err) // 에러 나면 return err | 54 | if(err) return next(err) // 에러 나면 return err |
55 | user.password = hash // 성공하면 user.password를 hash로 교체 | 55 | user.password = hash // 성공하면 user.password를 hash로 교체 |
56 | next() | 56 | next() | ... | ... |
-
Please register or login to post a comment