You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
31 lines
635 B
31 lines
635 B
const express = require('express');
|
|
const mysql = require('mysql');
|
|
const app = express();
|
|
|
|
const connection = mysql.createPool({
|
|
connectionLimit: 10,
|
|
host: process.env.MYSQL_HOST || 'localhost',
|
|
user: process.env.MYSQL_USER || 'root',
|
|
password: process.env.MYSQL_PASSWORD || 'password',
|
|
database: process.env.MYSQL_DATABASE || 'test'
|
|
});
|
|
|
|
app.get('/', (req, res) => {
|
|
connection.query('SELECT * FROM Student' , (err, rows) => {
|
|
if(err){
|
|
res.json({
|
|
success: false,
|
|
err
|
|
});
|
|
}
|
|
else{
|
|
res.json({
|
|
success: true,
|
|
rows
|
|
});
|
|
}
|
|
});
|
|
});
|
|
|
|
app.listen(5000, () => console.log('listining on port 5000'));
|