Skip to content

Commit 8fda77c

Browse files
committed
Merge pull request #145 from taylorstine/cloud_function
Added cloud funciton argument
2 parents 044fb52 + 95cea92 commit 8fda77c

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

index.js

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,9 @@ addParseCloud();
2424
// and delete
2525
// "databaseURI": a uri like mongodb://localhost:27017/dbname to tell us
2626
// what database this Parse API connects to.
27-
// "cloud": relative location to cloud code to require
27+
// "cloud": relative location to cloud code to require, or a function
28+
// that is given an instance of Parse as a parameter. Use this instance of Parse
29+
// to register your cloud code hooks and functions.
2830
// "appId": the application id to host
2931
// "masterKey": the master key for requests to this app
3032
// "facebookAppIds": an array of valid Facebook Application IDs, required
@@ -52,7 +54,14 @@ function ParseServer(args) {
5254
}
5355
if (args.cloud) {
5456
addParseCloud();
55-
require(args.cloud);
57+
if (typeof args.cloud === 'function') {
58+
args.cloud(Parse)
59+
} else if (typeof args.cloud === 'string') {
60+
require(args.cloud);
61+
} else {
62+
throw "argument 'cloud' must either be a string or a function";
63+
}
64+
5665
}
5766

5867
cache.apps[args.appId] = {

0 commit comments

Comments
 (0)