You can find the following code snippet in the Express documentation.
var mysql = require('mysql'); var connection = mysql.createConnection({ host : 'localhost', user : 'dbuser', password : 's3kreee7' }); connection.connect(); connection.query('SELECT 1 + 1 AS solution', function(err, rows, fields) { if (err) throw err; console.log('The solution is: ', rows[0].solution); }); connection.end(); Please tell us how safe this approach is (from injection and load in real projects) and how it should be stored in the root of the server folder. It is better to always break into modules (by MVC) and by files, and how to come to this?