0

I'm using a C++ add-on on my Node.js server. I'm trying to get the decrypt function which I imported from the file to run when the api is hit but the decrypt does nothing. Instead, when I leave the decrypt outside the route as commented, it works exactly as intended.

require('nan')
const { decrypt } = require('./build/Release/decrypt.node')

const express = require('express')
const fileupload = require('express-fileupload')
const app = express()

app.use(fileupload())

// decrypt() works fine here


app.post('/upload', (req, res) => {
    decrypt()
    res.send({
    status: true
  })
})

I've also tried importing it inside the body of the route but it didn't help.

kashif197
  • 23
  • 3
  • What does the JavaScript `decrypt` function return when called? – traktor Jun 16 '21 at 23:21
  • Is the decrypt module something that's public that we could look at the doc and code? What is it supposed to do? Just calling `decrypt()` with no arguments inside a request handler has no ability to do anything that is specific to that request because you don't pass it `req` or `res`. – jfriend00 Jun 17 '21 at 04:42

0 Answers0