could some one tell tell how to set different environment for node app.
I've came across lots of documentation/tutorials but could'nt understand how to make use of it as am new to node. kindly give me some help to achieve this with below basic code.
i got below from some tutorial about how to create basic server. i want run this app based on different parameter am passing. feel quite difficult to set config file for this. for example i need run this based on different location
var express = require('express');
var app = express();
var port = process.env.PORT || 3000;
var mongoose = require('mongoose');
var passport = require('passport');
var flash = require('connect-flash');
var morgan = require('morgan');
var cookieParser = require('cookie-parser');
var bodyParser = require('body-parser');
var session = require('express-session');
var configDB = require('./config/database.js');
var http = require('http').Server(app);
var MongoStore = require('connect-mongo')(session);
mongoose.connect(some_db.url);
mongoose.set('debug', false);
require('./config/passport')(passport);
app.use(morgan('dev'));
app.use(cookieParser());
app.use(bodyParser());
app.set('view engine', 'ejs');
app.use(session({
store: new MongoStore({
mongooseConnection: mongoose.connection /
}),
secret: 'screetservice',
resave: true,
saveUninitialized: true
}));
app.use(passport.initialize());
app.use(passport.session());
app.use(flash());
require('./app/routes.js')(app, passport, http);
//app.use(express.static(__dirname + '/public'));
app.use('/static', express.static(__dirname + '/public'));
console.log("Server sees:"+__dirname + '/public');
app.use( express.static( "public" ) );
app.use( express.static( "./app/public" ) );
http.listen(port);
console.log('The magic happens on port ' + port);
many thanks for any help
via my_first_step
No comments:
Post a Comment