36 lines
888 B
JavaScript
36 lines
888 B
JavaScript
|
/**
|
||
|
* Module dependencies.
|
||
|
*/
|
||
|
|
||
|
var express = require('express');
|
||
|
var routes = require('./routes');
|
||
|
var http = require('http');
|
||
|
var path = require('path');
|
||
|
var mysql = require('mysql'),
|
||
|
myConnection = require('express-myconnection');
|
||
|
|
||
|
var app = express();
|
||
|
|
||
|
// all environments
|
||
|
app.set('port', process.env.PORT || 3000);
|
||
|
app.set('views', __dirname + '/views');
|
||
|
app.set('view engine', 'ejs');
|
||
|
app.use(express.logger('dev'));
|
||
|
|
||
|
// It has to be registered somewhere before app.router
|
||
|
app.use(myConnection(mysql, {
|
||
|
host: process.env.DB_HOST,
|
||
|
user: process.env.DB_USER,
|
||
|
password: process.env.DB_PASSWORD,
|
||
|
port: process.env.DB_PORT,
|
||
|
database: process.env.DB_DATABASE
|
||
|
}, 'single'));
|
||
|
|
||
|
app.use(app.router);
|
||
|
|
||
|
app.get('/', routes.index);
|
||
|
|
||
|
http.createServer(app).listen(app.get('port'), function () {
|
||
|
console.log('Express server listening on port ' + app.get('port'));
|
||
|
});
|