Created
August 24, 2016 14:42
-
-
Save ShekharReddy4/fda2a7cecde91dc6fed3266312c73c83 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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