2021-02-26 00:00:23 UTC - Mina Michael: Hey guys. I have a question that should be very basic.
I have a very simple javascript file. It's meant to run in nodejs. It's basically a function that does simple queries to a mongodb database. Now, this function requires `mongodb` to run. Like this for example: `const { MongoClient } = require("mongodb");` Now, I'm trying to convert this js code into an openwhisk function. How do I correctly require libraries? Because in the general setting, I need to do `npm install --save mongodb`. https://openwhisk-team.slack.com/archives/C3TPCAQG1/p1614297623024100?thread_ts=1614297623.024100&cid=C3TPCAQG1 ---- 2021-02-26 01:53:46 UTC - Mina Michael: One more question. Does openwhisk support "async await"? Can I make "main" an async? And then, will openwhisk return what gets resolved? https://openwhisk-team.slack.com/archives/C3TPCAQG1/p1614304426026900?thread_ts=1614304426.026900&cid=C3TPCAQG1 ---- 2021-02-26 03:35:17 UTC - Mina Michael: I have created an `async function main() { }` and created a function on openwhisk. However, when I tried to invoke it, I got this error: ```{ "error": "Initialization has failed due to: Action entrypoint 'main' is not a function." }``` Is this because the function is async? Does that mean that async functions are not supported? Here is what I'm trying to do. I'm trying to create a function that does mongodb queries, and returns a result that depends on those queries. Without async support, how can I do it? https://openwhisk-team.slack.com/archives/C3TPCAQG1/p1614310517030100 ---- 2021-02-26 04:06:00 UTC - Mina Michael: I've tried with a non async function. Just one that returns a promise. I'm still getting the same error. ```{ "error": "Initialization has failed due to: Action entrypoint 'main' is not a function." }``` What can possibly be the cause of this? I thought it was related to async at first. I've been searching. Is it a bug? https://openwhisk-team.slack.com/archives/C3TPCAQG1/p1614312360031200 ---- 2021-02-26 04:07:44 UTC - Mina Michael: I have tried setting `--main global.main` like they say here <https://github.com/apache/openwhisk-runtime-nodejs/issues/138> but it didn't work. https://openwhisk-team.slack.com/archives/C3TPCAQG1/p1614312464031800 ---- 2021-02-26 04:43:35 UTC - Mina Michael: Okay. I have the same javascript function (non async). I have given it to openwhisk once as a js file and once inside a zip file. The first attempt (as a js file) worked completely fine. It returned the result. But the second one (as a zip file) didn't work. It gave the same error. I named the file "index.js" as requested by openwhisk. What can I be possibly doing wrong? https://openwhisk-team.slack.com/archives/C3TPCAQG1/p1614314615036500?thread_ts=1614314615.036500&cid=C3TPCAQG1 ----