-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.js
More file actions
40 lines (36 loc) · 1.35 KB
/
main.js
File metadata and controls
40 lines (36 loc) · 1.35 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
// const express = require('express');
// const app = express();
// pool = require("./config/database"),
// bodyParser = require('body-parser')
// //Middleware Set (2)
// app.use(bodyParser.json())
// app.use(bodyParser.urlencoded({extended : true}))
// /* POST : New User (3) */
// app.post("/", (req,res) => {
// //Request Param 추출
// const param = [req.body.idx, req.body.userid, req.body.userimg, req.body.title,
// req.body.content, req.body.viewc, req.body.regdate]
// //pool 실행
// pool((sql) => {
// //sql를 매개 변수 설정 시, sql.query로 sql Query 작성
// //데이터를 넣을 곳에 ?를 넣어 뒤의 매개 변수 param가 ?에 들어감
// sql.query("insert into tbl_user value(?,?,?,?,?,?,?)", param, (err, doc) => {
// //err가 있으면 err를 출력하고, 없으면 true를 보내줌
// err ? console.log(err) : res.send({result : true})
// })
// //DB 연결 해제
// sql.release()
// })
// })
// /* Get : Get Users (4) */
// app.get("/", (req,res) => {
// pool((sql) => {
// //가져온 DB 정보가 row에 배열 형식으로 담김
// sql.query("select * from board", (err, row) => {
// //err가 없으면 결과를 보내줌
// err ? console.log(err) : res.send({result : row})
// })
// //DB 연결 해제
// sql.release()
// })
// })