Error when using with Massive.js in Node.js

96 views Asked by At

I've been using massive.js within node for a couple months now and never ran into this error. I am completely stumped. Here is the code I am working with:

require('dotenv').config()

const{CONNECTION_STRING, SERVER_PORT, SESSION_SECRET} = process.env
const massive = require('massive')
const express = require('express')
const app = express()

const session = require('express-session')

app.use(express.json())

app.use(session({
    resave: true,
    saveUninitialized: false,
    secret: SESSION_SECRET,
    cookie: {
        maxAge: 1000 * 60 * 60 * 2
    }
}))

massive({
    connectionString: CONNECTION_STRING,
    ssl: {
        rejectUnauthorized: true
    }
})
.then(dbInstance => {
    app.set('db', dbInstance)
    app.listen(SERVER_PORT, () => console.log(`Server is bumping on ${SERVER_PORT}`))
})
.catch(err => console.log(err))

When I run nodemon, I get an error: "Error: self signed certificate". I know it has something to do with massive as when I take it out, nodemon connects to the server. When I change the value of rejectUnauthorized to false I get this error: "TypeError: client.ref is not a function". I have tried running "process.env.NODE_TLS_REJECT_UNAUTHORIZED = "0" on the command line and within the code but no luck. Any sort of help would be appreciated.

0

There are 0 answers