Posts
Q&A
jwt ์ passport-jwt ์ ๋ํด์ ์ง๋ฌธ ํ๋๋ง ๋๋ฆฌ๊ฒ ์ต๋๋ค.
์ข์ ๋ต๋ณ ๋ ๊ฐ์ฌ๋๋ฆฝ๋๋ค!!
- 0
- 2
- 477
Q&A
cookie.sign ๊ด๋ จ ์ง๋ฌธ ํ๋ ๋๋ฆฌ๊ฒ ์ต๋๋ค.
๋ต๋ณ ๊ฐ์ฌ๋๋ฆฝ๋๋ค. ๊ทธ๋ฌ๋ฉด ๊ตต๊ฒ ์น ํด์ง ๋ถ๋ถ์ด ๊ฐ์ ์ ์๋ ์ด์ ๋ ํ์ฌ ์ ๊ฐ์ ๋ก์ปฌ์๋ฒ์์ ๋์๊ฐ๊ธฐ ๋๋ฌธ์ ๋๊ฐ์ sinature ๊ฐ ๋ํด์ง๋ค๊ณ ์๊ฐํ๋ฉด ๋ ๊น์??
- 0
- 3
- 285
Q&A
์ง๋ฌธํ๋๋ง ๋๋ฆฌ๊ฒ ์ต๋๋ค.
์!! ์ด๋ค ๋๋์ธ์ง ์๊ฒ ์ต๋๋ค~ ๊ฐ์ฌํฉ๋๋ค !!
- 0
- 2
- 182
Q&A
matchedUrl ์ด ReferenceError๊ฐ ๋๋ฉด์ ์ข ๋ฃ๋ ๋
์...ํด๊ฒฐ๋์ต๋๋ค! ์ธ๋ฏธ์ฝ๋ก ๋ถ์ด๋ ์ต๊ด์ ๋ค์ฌ์ผ๊ฒ ๋ค์ ใ ใ ๊ฐ์ฌํฉ๋๋ค!
- 0
- 4
- 199
Q&A
matchedUrl ์ด ReferenceError๊ฐ ๋๋ฉด์ ์ข ๋ฃ๋ ๋
๋น ๋ฅธ ๋ต๋ณ ๊ฐ์ฌ๋๋ฆฝ๋๋ค!! ์ง์ ์ด์ ์์์ผ ๋ดค์ต๋๋ค. ์ด๋ฏธ ์์ ์ฐ๊ธด ํ์ต๋๋ค.. ๋ฐฉ๊ธ๋ ๋ค์ ํ๋ฒ ํด๋ดค๋๋ฐ ์๋๋ค์ ใ ใ ์คํ ์ฝ๋ ํ ๋ฒ๋ง ๋ด์ฃผ์๋ฉด ๊ฐ์ฌํ๊ฒ ์ต๋๋ค. ๋ชจ๋ ๋ถ๋ถ ์ ์ธํ๊ณ , ์ผ๋จ ๋ค ๋ณต๋ถ ํด๋๊ธด ํ์ต๋๋ค. ์ ๊ฐ ๋ญ๊ฐ ๋ฐ๋ผ์ฐ๋ค๊ฐ ๋์น๊ฑด์ง...ใ ใ console.log(mathedUrl) ๊ฒฐ๊ณผ๊ฐ : [Function: /] //๋ฆฌํฉํ ๋ง ์์ผ๋ณด์. express ๊ฐ ์๋ ์์ node ๋ก ์ง์ผํ ๋. const router = { get : { '/' : (req, res) => { fs.readFile('./restFront.html' , (err, data) => { if (err) { throw err } res.end(data); }); }, '/users' : (req, res) => { res.end(JSON.stringify(users)); }, // wild Card!! ์ด์ธ์ ๋ชจ๋ ์ผ์ด์ค. '*' : (req, res) => { fs.readFile(`.${req.url}`, (err, data) => { return res.end(data) }); }, }, post : { '/users' : (req, res) => { let body = ''; req.on('data', (chunk) => { body += chunk; }) req.on('end', () => { console.log('Post ๋ณธ๋ฌธ(body)', body); const { name } = JSON.parse(body); const id = +new Date(); users[id] = name res.writeHead(201, {'Content-Type' : 'text/html; charset=utf-8'}); //์ด๋ ๊ฒ ํด์ผ ํ๊ธ์ด ์๊นจ์ง. res.end('์ฌ์ฉ์ ๋ฑ๋ก ์ฑ๊ณต') }); } }, patch : { }, delete : { '/users' : (req, res) => { const key = req.url.split('/')[2]; let body = ''; req.on('data', (chunk) => { body += chunk; }); return req.on('end', () => { console.log('delete', body); delete users[key] return res.end(JSON.stringify(users)) }); }, }, put : { '/users' : (req, res) => { const key = req.url.split('/')[2]; let body = ''; req.on('data', (chunk) => { body += chunk; }); return req.on('end', () => { console.log('put', body); users[key] = JSON.parse(body).name; return res.end(JSON.stringify(users)) }) }, } } http.createServer((req, res) => { // ์ฐ๋ฆฌ๊ฐ ๋ง๋ ๋ผ์ฐํฐ ๊ฐ์ฒด๋ฅผ ์ด์ฉํด๋ณด์. // const matchedUrl = router[req.method.toLowerCase()][req.url] console.log(matchedUrl) (matchedUrl || router[req.method.toLowerCase()]['*'])(req, res); }).listen(5129, () => { console.log('5129 ๋ฒ ํฌํธ์์ ์๋ฒ ๋๊ธฐ ์ค') })
- 0
- 4
- 199