I have the following in my app.js
file:
var mysql = require('mysql');
var connection = mysql.createConnection({
host: 'localhost',
port: 3306,
user: 'user',
password: 'password',
database: 'mydatabase'
});
connection.connect();
In routes/index.js
, I currently have only the boilerplate code:
var express = require('express');
var router = express.Router();
module.exports = router;
How do I make available the connection
object from the app.js
file in routes/index.js
?