index.js 947 Bytes
var express = require('express')

var app = express()

var mysql = require('mysql')

var router = express.Router();

var path = require('path')

var passport = require('passport')
var LocalStrategy = require('passport-local').Strategy;


var connection = mysql.createConnection({
    host: 'localhost',
    port: 3306,
    user: 'root',
    password: 'ksmhjh88',
    database: 'nodetest'
})

connection.connect()


router.get('/list', function (req, res) {

    res.render('customer.ejs');
})

// 1. /market , get
router.get('/',function(req,res){

    var responseData = {};

    var query = connection.query('select * from market', function(err, rows) {
        if(err) throw err;
        if(rows.length) {
            console.log(rows)
            responseData.result = 1;
            responseData.data = rows;
        } else {
            responseData.result = 0;
        }
        res.json(responseData)
    })
})


module.exports = router;