서주원

create new schema and add cards.json

...@@ -2,4 +2,12 @@ ...@@ -2,4 +2,12 @@
2 2
3 node_modules 3 node_modules
4 4
5 -¼ҽSW Ʈ.txt
...\ No newline at end of file ...\ No newline at end of file
5 +*.txt
6 +
7 +.env
8 +
9 +*.log
10 +
11 +npm-debug.log*
12 +
13 +
......
No preview for this file type
...@@ -7,6 +7,8 @@ const bcrypt=require('bcrypt-nodejs') ...@@ -7,6 +7,8 @@ const bcrypt=require('bcrypt-nodejs')
7 const rp=require('request-promise') 7 const rp=require('request-promise')
8 const morgan=require('morgan') 8 const morgan=require('morgan')
9 const cheerio=require('cheerio') 9 const cheerio=require('cheerio')
10 +const mysql=require('mysql')
11 +require('dotenv').config()
10 const app=express() 12 const app=express()
11 13
12 app.use(morgan('[:date[iso]] :method :status :url :response-time(ms) :user-agent')) 14 app.use(morgan('[:date[iso]] :method :status :url :response-time(ms) :user-agent'))
...@@ -21,6 +23,19 @@ app.use(function (req, res, next) { ...@@ -21,6 +23,19 @@ app.use(function (req, res, next) {
21 next() 23 next()
22 }) 24 })
23 25
26 +const connection=mysql.createConnection({
27 + host:process.env.DB_HOST,
28 + user:process.env.DB_USER,
29 + password:process.env.DB_PASSWORD,
30 + database:'user',
31 + port:''
32 +})
33 +
34 +let allCards=[]
35 +fs.readFile('cardskoKR.json',(err,data)=>{
36 + allCards=JSON.parse(data)
37 +})
38 +
24 app.use(session({ 39 app.use(session({
25 secret:'ambc@!vsmkv#!&*!#EDNAnsv#!$()_*#@', 40 secret:'ambc@!vsmkv#!&*!#EDNAnsv#!$()_*#@',
26 resave:false, 41 resave:false,
...@@ -38,4 +53,8 @@ app.get('/main',(req,res)=>{ ...@@ -38,4 +53,8 @@ app.get('/main',(req,res)=>{
38 fs.readFile('./views/main') 53 fs.readFile('./views/main')
39 res.writeHead(200, {'Content-Type': 'text/html'}) 54 res.writeHead(200, {'Content-Type': 'text/html'})
40 } 55 }
56 +})
57 +
58 +app.listen(process.env.SERVER_PORT || 3000,()=>{
59 + console.log('sample server is listening to port ' + process.env.SERVER_PORT)
41 }) 60 })
...\ No newline at end of file ...\ No newline at end of file
......
This diff could not be displayed because it is too large.
This diff could not be displayed because it is too large.
This diff is collapsed. Click to expand it.
...@@ -16,11 +16,14 @@ ...@@ -16,11 +16,14 @@
16 "bcrypt-nodejs": "0.0.3", 16 "bcrypt-nodejs": "0.0.3",
17 "body-parser": "^1.18.3", 17 "body-parser": "^1.18.3",
18 "cheerio": "^1.0.0-rc.2", 18 "cheerio": "^1.0.0-rc.2",
19 + "dotenv": "^6.1.0",
19 "express": "^4.16.4", 20 "express": "^4.16.4",
20 "express-session": "^1.15.6", 21 "express-session": "^1.15.6",
21 "fs": "0.0.1-security", 22 "fs": "0.0.1-security",
22 "morgan": "^1.9.1", 23 "morgan": "^1.9.1",
24 + "mysql": "^2.16.0",
23 "path": "^0.12.7", 25 "path": "^0.12.7",
26 + "request": "^2.88.0",
24 "request-promise": "^4.2.2" 27 "request-promise": "^4.2.2"
25 } 28 }
26 } 29 }
......