Hi folks,
I’ve got a somewhat similar question. I’d like have a parse instance per customer. A friend suggested that I simply create a totally new instance of parse (i.e. a totally separate and full set of all files) per customer. I guess this is a workable option, but I was wondering if I can use a single copy of my parse code and simply create separate parse application instances in the parse server setup?
I understand from what I’ve read in a few different places online that cloud code is not designed to be “isolated” in a multi-tenancy type situation, but I’m happy quite happy to share as single set of cloud functions between customers as they will be locked down and only editable by ourselves, not the customers. In fact, I would prefer this (Unless of course this implies that cloud coud would only be able to access a single app’s data?)
TL;DR:
My questions:
- Will this approach work? Is it just a case of figuring it out? or
- Can parse servers share a single code base but perhaps need to run in separate processes? or
- Do I need to treat each parse server as totally separate? i.e. totally separate copy of files and separate parse setup?
Thanks in advance
This is what I currently have setup:
const customers = [
{
appName: 'Customer One',
customerPath: 'customer-one',
databaseURI: 'mongodb://localhost:27017/customerOne',
serverURL: `${config.parse.serverUrl}/customer-one`,
publicServerURL: `${config.parse.serverUrl}/customer-one`,
masterKey: 'masterCustomerOne',
appId: 'Customer One App',
cloud: `${__dirname}/${config.parse.cloudFunctions}`
},
{
appName: 'Customer Two',
customerPath: 'customer-two',
databaseURI: 'mongodb://localhost:27017/customerTwo',
serverURL: `${config.parse.serverUrl}/customer-two`,
publicServerURL: `${config.parse.serverUrl}/customer-two`,
masterKey: 'masterCustomerTwo',
appId: 'Customer Two App',
cloud: `${__dirname}/${config.parse.cloudFunctions}`
}
]
const customerInstances = []
for (const customer of customers) {
const instance = new ParseServer(customer)
customerInstances.push(instance)
}
const apps = customers.map((customer) => {
return {
serverURL: serverURL: customer.serverURL,
masterKey: customer.masterKey,
appId: customer.appId,
appName: customer.appId
}
})
const parseDashboard = new ParseDashboard(
{
apps,
users: [
{
user: config.parse.adminUser,
pass: config.parse.adminPassword,
},
],
},
{
allowInsecureHTTP: !process.env.NODE_ENV || process.env.NODE_ENV !== "production"
},
);
I start this up locally and…
- In the terminal, I get a warning that the 2nd server is not running
- In the dashboard, I can see both apps registered, but only the the first is usable (expected, seeing as the terminal output already mentioned that the 2nd is not running)
- I can interact with the cloud functions via the rest api and I can add records via the js console.
I’ve already burnt a few hours in reading online to figure out if this approach will work, but I can’t seem to find anything.