@@ -106,7 +106,7 @@ Cloud.enqueue = function(name, params, options) {
106106 } , options ) ,
107107 authOptions : { useMasterKey : true }
108108 } ) ;
109- }
109+ } ;
110110
111111Cloud . beforeSave = function ( nameOrClass , func ) {
112112 defineClassHook ( className ( nameOrClass ) , '__before_save_for_' , func ) ;
@@ -154,9 +154,9 @@ AV.Insight.on = function(action, func) {
154154
155155Cloud . Error = class CloudError extends Error {
156156 constructor ( message , extra ) {
157- super ( )
157+ super ( ) ;
158158
159- extra = extra || { }
159+ extra = extra || { } ;
160160
161161 if ( ! extra . status ) {
162162 extra . status = 400 ;
@@ -165,11 +165,11 @@ Cloud.Error = class CloudError extends Error {
165165 _ . extend ( this , {
166166 name : 'CloudError' ,
167167 message : message
168- } , extra )
168+ } , extra ) ;
169169
170- Error . captureStackTrace ( this , this . constructor )
170+ Error . captureStackTrace ( this , this . constructor ) ;
171171 }
172- }
172+ } ;
173173
174174Cloud . logInByIdAndSessionToken = function ( uid , sessionToken , fetchUser , cb ) {
175175 if ( fetchUser ) {
@@ -208,3 +208,25 @@ function className(clazz) {
208208 throw new Error ( 'Unknown class:' + clazz ) ;
209209 }
210210}
211+
212+ const PORT = parseInt ( process . env . LEANCLOUD_APP_PORT || 3000 ) ;
213+ let server ;
214+
215+ Cloud . start = function ( ) {
216+ if ( ! AV . applicationId ) {
217+ AV . init ( {
218+ appId : process . env . LEANCLOUD_APP_ID ,
219+ appKey : process . env . LEANCLOUD_APP_KEY ,
220+ masterKey : process . env . LEANCLOUD_APP_MASTER_KEY ,
221+ } ) ;
222+ }
223+ server = AV . express ( ) . listen ( PORT , function ( ) {
224+ console . log ( 'LeanEngine Cloud Functions app is running, port:' , PORT ) ;
225+ } ) ;
226+ } ;
227+
228+ Cloud . stop = function ( ) {
229+ if ( server ) {
230+ server . close ( ) ;
231+ }
232+ } ;
0 commit comments