Skip to content

Instantly share code, notes, and snippets.

@ShekharReddy4
Created August 24, 2016 14:42
Show Gist options
  • Save ShekharReddy4/fda2a7cecde91dc6fed3266312c73c83 to your computer and use it in GitHub Desktop.
Save ShekharReddy4/fda2a7cecde91dc6fed3266312c73c83 to your computer and use it in GitHub Desktop.
// variables
var express = require('express');
var path = require('path');
var favicon = require('serve-favicon');
var bodyParser = require('body-parser');
var morgan = require('morgan');
var uuid = require('uuid');
var app = express();
console.log(uuid.v4());
// view engine setup
app.set('views', path.join(__dirname, 'views'));
app.set('view engine', 'ejs');
// favicon setup
app.use(favicon(path.join('public', 'favicon.ico')));
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: true }));
app.use(express.static(path.join(__dirname, 'public')));
app.use(morgan('dev'));//this package logs the requests and errors in the console (needed for dev not intended for production purpose)
var db = require('./db');
var routes= require('./routes');
routes(app, db);
module.exports = app;
var mysql = require('mysql');
// set the mysql properties
var connection = mysql.createConnection({
host : 'localhost',
user : 'root',
password : 'root',
database : 'atlas'
});
connection.connect()
module.exports = connection;
module.exports = function(app, db) {
function importRoute(routeName) {
var routeModule = require('./' + routeName);
app.use(routeModule(db));
}
importRoute('default');
importRoute('distributions');
importRoute('markerSites');
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment