@@ -21,24 +21,32 @@ import { exec } from 'child_process';
21
21
import { createTransport } from 'nodemailer' ;
22
22
import { app as v1 } from './cloud/customRoute/v1/apiV1.js' ;
23
23
import { PostHog } from 'posthog-node' ;
24
- const spacesEndpoint = new AWS . Endpoint ( process . env . DO_ENDPOINT ) ;
25
24
// console.log("configuration ", configuration);
25
+ let fsAdapter ;
26
26
if ( process . env . USE_LOCAL !== 'TRUE' ) {
27
- const s3Options = {
28
- bucket : process . env . DO_SPACE , // globalConfig.S3FilesAdapter.bucket,
29
- baseUrl : process . env . DO_BASEURL ,
30
- region : process . env . DO_REGION ,
31
- directAccess : true ,
32
- preserveFileName : true ,
33
- s3overrides : {
34
- accessKeyId : process . env . DO_ACCESS_KEY_ID ,
35
- secretAccessKey : process . env . DO_SECRET_ACCESS_KEY ,
36
- endpoint : spacesEndpoint ,
37
- } ,
38
- } ;
39
- var fsAdapter = new S3Adapter ( s3Options ) ;
27
+ try {
28
+ const spacesEndpoint = new AWS . Endpoint ( process . env . DO_ENDPOINT ) ;
29
+ const s3Options = {
30
+ bucket : process . env . DO_SPACE , // globalConfig.S3FilesAdapter.bucket,
31
+ baseUrl : process . env . DO_BASEURL ,
32
+ region : process . env . DO_REGION ,
33
+ directAccess : true ,
34
+ preserveFileName : true ,
35
+ s3overrides : {
36
+ accessKeyId : process . env . DO_ACCESS_KEY_ID ,
37
+ secretAccessKey : process . env . DO_SECRET_ACCESS_KEY ,
38
+ endpoint : spacesEndpoint ,
39
+ } ,
40
+ } ;
41
+ fsAdapter = new S3Adapter ( s3Options ) ;
42
+ } catch ( err ) {
43
+ console . log ( 'Please provide AWS credintials in env file! Defaulting to local storage.' ) ;
44
+ fsAdapter = new FSFilesAdapter ( {
45
+ filesSubDirectory : 'files' , // optional, defaults to ./files
46
+ } ) ;
47
+ }
40
48
} else {
41
- var fsAdapter = new FSFilesAdapter ( {
49
+ fsAdapter = new FSFilesAdapter ( {
42
50
filesSubDirectory : 'files' , // optional, defaults to ./files
43
51
} ) ;
44
52
}
@@ -66,7 +74,6 @@ if (process.env.SMTP_ENABLE) {
66
74
67
75
mailgunDomain = process . env . MAILGUN_DOMAIN ;
68
76
}
69
-
70
77
export const config = {
71
78
databaseURI :
72
79
process . env . DATABASE_URI || process . env . MONGODB_URI || 'mongodb://localhost:27017/dev' ,
@@ -75,17 +82,19 @@ export const config = {
75
82
} ,
76
83
appId : process . env . APP_ID || 'myAppId' ,
77
84
maxLimit : 500 ,
78
- masterKey : process . env . MASTER_KEY || '' , //Add your master key here. Keep it secret!
85
+ masterKey : process . env . MASTER_KEY , //Add your master key here. Keep it secret!
79
86
masterKeyIps : [ '0.0.0.0/0' , '::1' ] , // '::1'
80
87
serverURL : process . env . SERVER_URL || 'http://localhost:8080/app' , // Don't forget to change to https if needed
81
- verifyUserEmails : true ,
88
+ verifyUserEmails : process . env . SMTP_ENABLE || process . env . MAILGUN_API_KEY ? true : false ,
82
89
publicServerURL : process . env . SERVER_URL || 'http://localhost:8080/app' ,
83
90
// Your apps name. This will appear in the subject and body of the emails that are sent.
84
91
appName : 'Open Sign' ,
85
92
allowClientClassCreation : false ,
86
- emailAdapter :
87
- process . env . SMTP_ENABLE || process . env . MAILGUN_API_KEY
88
- ? {
93
+ allowExpiredAuthDataToken : false ,
94
+ encodeParseObjectInCloudFunction : true ,
95
+ ...( process . env . SMTP_ENABLE || process . env . MAILGUN_API_KEY
96
+ ? {
97
+ emailAdapter : {
89
98
module : 'parse-server-api-mail-adapter' ,
90
99
options : {
91
100
// The email address from which emails are sent.
@@ -116,8 +125,9 @@ export const config = {
116
125
} else if ( transporterMail ) await transporterMail . sendMail ( payload ) ;
117
126
} ,
118
127
} ,
119
- }
120
- : null ,
128
+ } ,
129
+ }
130
+ : { } ) ,
121
131
filesAdapter : fsAdapter ,
122
132
auth : {
123
133
google : {
@@ -170,9 +180,13 @@ app.use('/public', express.static(path.join(__dirname, '/public')));
170
180
// Serve the Parse API on the /parse URL prefix
171
181
if ( ! process . env . TESTING ) {
172
182
const mountPath = process . env . PARSE_MOUNT || '/app' ;
173
- const server = new ParseServer ( config ) ;
174
- await server . start ( ) ;
175
- app . use ( mountPath , server . app ) ;
183
+ try {
184
+ const server = new ParseServer ( config ) ;
185
+ await server . start ( ) ;
186
+ app . use ( mountPath , server . app ) ;
187
+ } catch ( err ) {
188
+ console . log ( err ) ;
189
+ }
176
190
}
177
191
// Mount your custom express app
178
192
app . use ( '/' , customRoute ) ;
@@ -196,8 +210,12 @@ if (!process.env.TESTING) {
196
210
httpServer . headersTimeout = 100000 ; // in milliseconds
197
211
httpServer . listen ( port , function ( ) {
198
212
console . log ( 'parse-server-example running on port ' + port + '.' ) ;
199
- const migrate = `APPLICATION_ID=${ process . env . APP_ID } SERVER_URL=http://localhost:8080/app MASTER_KEY=${ process . env . MASTER_KEY } npx parse-dbtool migrate` ;
213
+ const isWindows = process . platform === 'win32' ;
214
+ // console.log('isWindows', isWindows);
200
215
216
+ const migrate = isWindows
217
+ ? `set APPLICATION_ID=${ process . env . APP_ID } && set SERVER_URL=http://localhost:8080/app&& set MASTER_KEY=${ process . env . MASTER_KEY } && npx parse-dbtool migrate`
218
+ : `APPLICATION_ID=${ process . env . APP_ID } SERVER_URL=http://localhost:8080/app MASTER_KEY=${ process . env . MASTER_KEY } npx parse-dbtool migrate` ;
201
219
exec ( migrate , ( error , stdout , stderr ) => {
202
220
if ( error ) {
203
221
console . error ( `Error: ${ error . message } ` ) ;
@@ -211,6 +229,4 @@ if (!process.env.TESTING) {
211
229
console . log ( `Command output: ${ stdout } ` ) ;
212
230
} ) ;
213
231
} ) ;
214
- // This will enable the Live Query real-time server
215
- await ParseServer . createLiveQueryServer ( httpServer ) ;
216
232
}
0 commit comments