Search code examples
javascriptnode.jsdeployd

How to access to the Node.js Filesystem API from Deployd (deployd.com)?


I am using Deployd (deployd.com) to create an API easily. I want to create a HTML file on post event. The problem is that it doesn't work because "require" is not defined. I think that it's because the Node.js API is not accessible from Deployd. The documentation related is here: http://docs.deployd.com/docs/collections/adding-logic.md, and it says: "Events allow you to add custom business logic to your Collection. By writing Events, you can add validation, relationships, and security to your app. Events are written in JavaScript (specifically, the ECMAScript 5 standard) and have access to the Collection Events API."

So, is there a way to have access to the Node.js API or, alternatively, any way to create a file with Deployd?

Thanks!!!


Solution

  • You can enable require() in event scripts by adding the following gist to the node_modules directory: Exposing Require

    But I believe the best way to do it is to create your own custom resource type. That way, you won't be restricted by what can only be done inside event scripts.