-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
34 lines (30 loc) · 1.37 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
var express = require("express"),
app = express(),
bodyParser = require("body-parser"),
methodOverride = require("method-override");
http = require("http"),
server = http.createServer(app),
mongoose = require('mongoose'),
URI = process.env.MONGODB_URI || 'mongodb://localhost/startFastNode',
PORT = process.env.PORT || 5001,
path = require('path'),
engines = require('consolidate'),
db = mongoose.connection;
app.use(bodyParser.urlencoded({ extended: false }));
app.use(bodyParser.json());
app.use(methodOverride());
require('./config/routes/routes-user-example')(app);
//================MONGODB==================//
mongoose.connect(URI,{ useMongoClient: true }, (err, res) =>{
if (err) return console.log("Error MongoDB -->",err.message)
return console.log("Succes! MongoDB run fine")
})
//==================API + Aplicacion==================//
app.use(express.static(path.join(__dirname, 'public')))
app.set('view engine', 'ejs');
app.get('/', function(req, res) {
res.render('body');
});
app.get('/', (req, res) => res.render('body'))
app.listen(PORT, () => console.log(`Listening on ${ PORT }`))
//Start environment of Node with Express, Mongoose, EJS and an example of login User (with password encrypted) Bcrypt-nodejs