0

I am learning NODEJS addons building

I was able to build a simple application but now I have a problem in connecting to the database using addons and passing query data to NODEJS

Can anyone suggest me what should I do??

I am developing my application using electron so one main issue in electron is it's asar file even though it's protected it can access by anyone and get the password and other stuff to the database so what I am trying to do is create a nodejs c++ addons and pass query and run query in c++ and get query result back to front as a string or something and process them in frontend now I was able to create addon but still couldn't find a way to connect to database c++ there is nothing in anywhere a way to connect to the database in c++ addons actually I don't know is it possible or not but it's worth trying. now I know how to connect to database in pure c++ and when i try to do it in here it can't find libraries.

  • I guess nobody could help without more specific information about what you are trying to do. – TGrif Mar 15 '20 at 14:06
  • I have developed everything using nodejs (electron) but there are some security issues so I am trying to do all database communication in c++ addons so i can call those c++ function and get the result as a string or something and process them in front so no one can change or do anything even they get to asar file – Thalinda Bandara Mar 15 '20 at 14:20
  • It looks very interesting, could you clarify in your question where do you actually have a problem ? – TGrif Mar 15 '20 at 14:25
  • I have updated it thank you verymuch for quick replys – Thalinda Bandara Mar 15 '20 at 14:36
  • What kind of database connection are you using that you need to store the password in the application? Also just rewriting it in C++ does not mean that people wouldn't be able to retrieve the password, it would only become a tiny bit harder for them to do so – UnholySheep Mar 15 '20 at 14:39
  • when creating database connection I have to give everything user name password database and host so what I am trying to do is transfer all database activities to the backend(c++) and when I run `node-gyp configure build` all those codes are converted to bite code correct so no one can access them am i correct? really sorry if am bluffing i just learned c++ addons 2 days ago – Thalinda Bandara Mar 15 '20 at 14:48
  • 1
    Strings (which include passwords) are still stored in more or less readable state somewhere, even if you compile the C++ code to machine code. And I'm still unsure what exactly you are trying to protect with your approach - a local user can read any kind of data that goes out from their PC if they are interested enough. If the database is on an external server you should **never** connect directly to it, that's unsafe for a dozen other reasons anyway – UnholySheep Mar 15 '20 at 15:29
  • sorry for the delay my application or databases not hosted anywhere it's located in the same machine for now I know it's safe I have created an admin profile and block access to the c drive still I need to think about the worst-case scenario that's why I am trying this approach. and another option is to host my database connection files and query files in servers and database also in a server and call them using HTTP request and use it as REST API but I still feel like there could be some success using this approach (**and I really love electron easy and fast**) – Thalinda Bandara Mar 16 '20 at 11:48

0 Answers0