ADD: redis client and connection
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
const mongoose = require('mongoose')
|
||||
const redisClient = require('./redis')
|
||||
const port = process.env.PORT || 3000
|
||||
const env = process.env.NODE_ENV || 'development'
|
||||
module.exports = (app) => {
|
||||
@@ -14,15 +15,19 @@ module.exports = (app) => {
|
||||
.connect(connectionString, {})
|
||||
.then(async function () {
|
||||
console.log('MongoDB Database Connected')
|
||||
const MyModel = mongoose.model('MyCollection', new mongoose.Schema({name: String}));
|
||||
const MyModel = mongoose.model('MyCollection', new mongoose.Schema({ name: String }))
|
||||
|
||||
// Create a document to force MongoDB to actually create the DB and collection
|
||||
await MyModel.create({name: 'test'});
|
||||
await MyModel.create({ name: 'test' })
|
||||
|
||||
redisClient.connect().then((r) => {
|
||||
console.log('Redis connection Established')
|
||||
|
||||
app.listen(port, function () {
|
||||
console.log('Server Started On Port ' + port)
|
||||
})
|
||||
})
|
||||
})
|
||||
.catch(function (err) {
|
||||
console.log(err)
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user