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