forked from yongjhih/docker-parse-server
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
executable file
·110 lines (92 loc) · 3.23 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
#!/usr/bin/env node
// ref. parse-server/index.js
// ref. parse-server/bin/parse-server
var express = require('express');
var ParseServer = require('parse-server').ParseServer;
var links = require('docker-links').parseLinks(process.env);
var databaseUri = process.env.DATABASE_URI || process.env.MONGOLAB_URI;
if (!databaseUri) {
if (links.mongo) {
databaseUri = 'mongodb://' + links.mongo.hostname + ':' + links.mongo.port + '/dev';
}
}
if (!databaseUri) {
console.log('DATABASE_URI not specified, falling back to localhost.');
}
var facebookAppIds = process.env.FACEBOOK_APP_IDS;
if (facebookAppIds) {
facebookAppIds = facebookAppIds.split(",");
}
var gcmId = process.env.GCM_ID;
var gcmKey = process.env.GCM_KEY;
var productionPfx = process.env.PRODUCTION_PFX;
var productionBundleId = process.env.PRODUCTION_BUNDLE_ID;
var devPfx = process.env.DEV_PFX;
var devBundleId = process.env.DEV_BUNDLE_ID;
var pushConfig;
if ((gcmId && gcmKey) || (productionPfx && productionBundleId) || (devBundleId && devPfx)) {
pushConfig = {
android: {
senderId: process.env.GCM_ID || '',
apiKey: process.env.GCM_KEY || ''
},
ios: [
{
pfx: process.env.DEV_PFX || '',
bundleId: process.env.DEV_BUNDLE_ID || '',
production: false
},
{
pfx: process.env.PRODUCTION_PFX || '',
bundleId: process.env.PRODUCTION_BUNDLE_ID || '',
production: true
}
]
};
}
var serverURL = process.env.SERVER_URL || 'http://localhost:1337'; // Don't forget to change to https if needed
var api = new ParseServer({
databaseURI: databaseUri || 'mongodb://localhost:27017/dev',
cloud: process.env.CLOUD_CODE_MAIN || __dirname + '/cloud/main.js',
appId: process.env.APP_ID || 'myAppId',
masterKey: process.env.MASTER_KEY, //Add your master key here. Keep it secret!
serverURL: serverURL,
collectionPrefix: process.env.COLLECTION_PREFIX,
clientKey: process.env.CLIENT_KEY,
restAPIKey: process.env.REST_API_KEY,
dotNetKey: process.env.DOTNET_KEY,
javascriptKey: process.env.JAVASCRIPT_KEY,
dotNetKey: process.env.DOTNET_KEY,
fileKey: process.env.FILE_KEY,
facebookAppIds: facebookAppIds,
maxUploadSize: process.env.MAX_UPLOAD_SIZE,
push: pushConfig,
verifyUserEmails: process.env.VERIFY_USER_EMAILS,
enableAnonymousUsers: process.env.ENABLE_ANON_USERS,
allowClientClassCreation: process.env.ALLOW_CLIENT_CLASS_CREATION,
//oauth = {},
appName: process.env.APP_NAME,
publicServerURL: process.env.PUBLIC_SERVER_URL
//customPages: process.env.CUSTOM_PAGES || // {
//invalidLink: undefined,
//verifyEmailSuccess: undefined,
//choosePassword: undefined,
//passwordResetSuccess: undefined
//}
});
var app = express();
if(process.env.TRUST_PROXY == 1) {
console.log("trusting proxy");
app.enable('trust proxy');
}
// Serve the Parse API on the /parse URL prefix
var mountPath = process.env.PARSE_MOUNT || '/parse';
app.use(mountPath, api);
// Parse Server plays nicely with the rest of your web routes
app.get('/', function(req, res) {
res.status(200).send('I dream of being a web site.');
});
var port = process.env.PORT || 1337;
app.listen(port, function() {
console.log('parse-server-example running on ' + serverURL + ' (:' + port + mountPath + ')');
});