Skip to content

Commit

Permalink
rest server usuario
Browse files Browse the repository at this point in the history
  • Loading branch information
nestorsgarzonc committed Oct 19, 2020
1 parent 1cd145d commit a28324a
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 2 deletions.
17 changes: 17 additions & 0 deletions server/config/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,20 @@
//======================

process.env.PORT = process.env.PORT || 3000

//======================
//Entorno
//======================
process.env.NODE_ENV = process.env.NODE_ENV || 'dev'

//======================
//DB
//======================

let urlDB;
if (process.env.NODE_ENV === 'dev') {
urlDB = 'mongodb://127.0.0.1:27017/waffly'
} else {
urlDB = 'mongodb+srv://admin-nw:[email protected]/waffly'
}
process.env.URLDB = urlDB;
2 changes: 1 addition & 1 deletion server/routes/user.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ app.get('/usuario', function (req, res) {
if (err) {
return res.status(400).json({ ok: false, err })
}
Usuario.count({ estado: true }, (err, counter) => {
Usuario.estimatedDocumentCount({ estado: true }, (__, counter) => {
res.json({ ok: true, counter, usuarios })
})
})
Expand Down
2 changes: 1 addition & 1 deletion server/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ app.use(bodyParser.json())

app.use(require('./routes/user'))

mongoose.connect('mongodb://127.0.0.1:27017/waffly', {
mongoose.connect(process.env.URLDB, {
useNewUrlParser: true,
useUnifiedTopology: true,
useFindAndModify: false,
Expand Down

0 comments on commit a28324a

Please sign in to comment.