Moralis in Nodejs

Can anyone here please point me to use cases for moralis/node
I am not sure what the intended use for it is supposed to be plus I cant use moralis with Typescript currently and that is such a pain, given that import Moralis from 'moralis/node would through an error

Also is it possible to leverage the serverUrl directly. if so, what will the authentication mechanism be.

The use case I am trying to leverage is one that treats Moralis like a microservice for my nodejs backend, which will enable us use the fine aspects of moralis as an integration layer for all things blockchain

1 Like

Could you kindly add a code snippet as well as a screenshot of the error so that all of us here can help you debug your issue? Thanks

1 Like

Using the import syntax for Moralis in typescript Nodejs throws an Error
Either by calling import Moralis from 'moralis/node' or import Moralis from 'moralis'

webpack:/apps/guardian/src/app/accounts/investor/investors.resolver.ts:19
Moralis.initialize(M_APP_ID)
        ^
TypeError: Cannot read property 'initialize' of undefined
    at Object../apps/guardian/src/app/accounts/investor/investors.resolver.ts (/srv/cent/centio/dist/apps/guardian/webpack:/apps/guardian/src/app/accounts/investor/investors.resolver.ts:19:9)

The use case I am exploring can be described as so,

  • user signups on client
  • account information is created on Moralis
  • because the application has a couple other TradFi dependencies information from these dependencies are stitched together to enrich client data.

I’ve managed to figure this out though, and currently using the require('moralis/node') to get going, also having to tinker with the SDK code and docs to find my way around.

Hopefully there is properly documentation of the SDK API, to enable developers get around quite fast

Better Typescript support is something that will be addressed in the future.

Use moralis/node in a backend (NodeJS) environment like the microservice you describe. There are differences in how the code works in the browser vs. a standalone app that require separate versions.

If you have any specific suggestions to improve the docs please let us know. Particularly if things are confusing, missing, lacking examples, or incorrect.

https://docs.moralis.io/

3 Likes