Search code examples
javascriptnode.jsparse-cloud-codeparse-server

Writing server side code using nodejs on parse server app


How would I go about starting to write server code using node js, and be able to utilize it through my parse server managed app.

Similar to what cloudCode does, expect that I want to use nodejs, and Parse state that "cloudCode is not nodejs".

Is it as simple as writing a nodejs module and redirecting requests and data to it, and send back information?

If there is a tutorial or something that I can start with, that will be great!. Thank you!


Solution

  • If you want your Parse-Server-based code to call your regular express JS modules (maybe defined inside a route file), then that would mean requiring the express JS defined module (i.e. require('./path/to/modulefile') ) in the CloudCode functions definition file, and then calling the methods and properties you've defined in the module.

    If, on the other hand, you want your express JS modules to use functionalities you've defined in your CloudCode file (which should be by default in './cloud/' directory), then, within your express JS module (maybe inside a route file, etc), you can use Parse.Cloud.run('functionDefinedInCloudCodeFile', {parametersToBePassed}); to invoke the functionality you want.

    Hope that helps.