-
-
Notifications
You must be signed in to change notification settings - Fork 4.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added multi-app support in DatabaseAdapter.js #139
Conversation
Sure, looks good. Thanks. 👍 |
Added multi-app support in DatabaseAdapter.js
It's worked.
var express = require('express');
var ParseServer = require('parse-server').ParseServer;
var app = express();
var api = new ParseServer({
databaseURI: 'mongodb://localhost:27017/dev', // Connection string for your MongoDB database
cloud: '/home/parse/parse-server/cloud/main.js', // Absolute path to your Cloud Code
appId: 'bb',
masterKey: 'your-master-key', // Keep this key secret!
serverURL: 'http://localhost:1337/parse' // Don't forget to change to https if needed
});
app.use('/parse/bb', api);
var api2 = new ParseServer({
databaseURI: 'mongodb://localhost:27017/dev2', // Connection string for your MongoDB database
cloud: '/home/parse/parse-server/cloud/main.js', // Absolute path to your Cloud Code
appId: 'cc',
masterKey: 'your-master-key', // Keep this key secret!
serverURL: 'http://localhost:1337/parse' // Don't forget to change to https if needed
});
app.use('/parse/cc', api2);
app.listen(1337, function() {
console.log('parse-server-example running on port 1337.');
});
|
It Wont Work With cloud code.... |
@flovilmart Would it work if I use |
@ralphilius You can try this.
var express = require('express');
var ParseServer = require('parse-server').ParseServer;
var moment = require('moment');
var app = express();
var api_app1 = new ParseServer({
databaseURI: 'mongodb://localhost:27017/dbApp1', // Connection string for your MongoDB database
cloud: '/home/parse/parse-server/apps/app1/cloud/main.js', // Absolute path to your Cloud Code
appId: 'app1',
masterKey: 'the_masterKey', // Keep this key secret!
serverURL: 'http://localhost:1337/parse' // Don't forget to change to https if needed
});
app.use('/parse/app1', api_app1);
var api_app2 = new ParseServer({
databaseURI: 'mongodb://localhost:27017/dbApp2', // Connection string for your MongoDB database
cloud: '/home/parse/parse-server/apps/app2/cloud/main.js', // Absolute path to your Cloud Code
appId: 'app2',
masterKey: 'the_masterKey', // Keep this key secret!
serverURL: 'http://localhost:1337/parse' // Don't forget to change to https if needed
});
app.use('/parse/app2', api_app2);
app.listen(1337, function() {
var dateNow = moment(new Date()).format("YYYY-MMM-D HH:mm --> ");
console.log(dateNow + 'parse-server running on port 1337.');
});
{
"apps": [{
"serverURL": "https://youdomain.com/parse/app1",
"appId": "app1",
"masterKey": "the_masterKey",
"appName": "app1"
},{
"serverURL": "https://youdomain.com/parse/app2",
"appId": "app2",
"masterKey": "the_masterKey",
"appName": "app2"
}],
"users": [{
"user":"user1",
"pass":"pass"
},{
"user":"user2",
"pass":"pass"
}]
}
{
"apps" : [{
"name" : "parse-apps",
"script" : "/usr/bin/node",
"watch" : true,
"merge_logs" : true,
"cwd" : "/home/parse/parse-server",
"args" : "index.js"
},{
"name" : "parse-dashboard",
"script" : "/usr/bin/parse-dashboard",
"watch" : true,
"merge_logs" : true,
"cwd" : "/home/parse/parse-server",
"args" : "--config parse-dashboard-config.json --mountPath /dashboard"
}]
} then, |
Thanks for verifying @ucoker |
Your clous code won't work |
how to create dynamically ......like back4app. |
you can run with parse-server-example or other methods multi apps instance. there is one problem, creating more then 10 apps will brake the run time, because at ParseServer.js there is a listening to event process.on('uncaughtException', ...) which can run only ten times. the difference between the apps is by the http request credentials. good lock! |
When you create multi app instance in this way,The param global.Parse.Cloud will be overwritten util all instances created.I agree @flovilmart |
The feature for multi app instance is uncompleted in parse-server 2.3.1 |
LiveQuery does not work it this way. Any body can solve it? |
When creating multiple instances of
ParseServer
to connect to different databases using a single server, thedatabaseURI
was getting overwritten by the last defined connection string (issue: #116).This patch stores each connection string by
appId
so that they're not overwritten when creating newParseServer
objects.This patch then allows the user to host multiple apps on the same server like this:-