1

I have a parse-server hosted by heroku, which has an index.js file utilized for its configuration. I want to use Mailgun to up functionality for the user to request a password reset, and I have set up the config file, following this answer, as follows:

var api = new ParseServer({
  appName: 'App Name',
  publicServerURL: 'https://<name>.herokuapp.com/parse',
  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 $
  serverURL: process.env.SERVER_URL || 'http://localhost:1337/parse',  // Don't$
  liveQuery: {
    classNames: ["Posts", "Comments"] // List of classes to support for query s$
  },
  push: JSON.parse(process.env.SERVER_PUSH || "{}"),
  verifyUserEmails: true, //causing errors
  emailAdapter: { //causing errors
    module: 'parse-server-simple-mailgun-adapter',
    options: { 
             fromAddress: 'parse@example.com',
             domain: '<domain>', 
             apiKey: '<key>', 
           }
  }
});

This code does not work, though, because of the verifyUserEmails and emailAdapter. Removing both of them removes the "JSON text did not start with array" error. Adding either one of them back in results in the error being thrown. I have no idea why, though, since I do not see any obvious reason as to how they aren't being set up in an array correctly?
Do I need to set up the cooresponding config vars in heroku in addition to having them in the config file? I considered this, but appName and publicServerURL are not set up in this way and don't give this error.

Runeaway3
  • 1,439
  • 1
  • 17
  • 43

2 Answers2

0

emailAdapter.options.apiKey doesn't need a comma at the end since its the last element of it's JSON.

I wouldn't be surprised that you're also leaving in the comma at the end of verifyUserEmails when you include it improperly as well.

options: { 
             fromAddress: 'parse@example.com',
             domain: '<domain>', 
             apiKey: '<key>', 
           }

This is not valid JSON, because there is a comma at the end of the apiKey line. The last item in a JSON object does not have a comma.

Jake T.
  • 4,308
  • 2
  • 20
  • 48
0

For anyone that is repeatedly running into this issue, I have figured out exactly what was going wrong. Despite the error informing me that my JSON was incorrectly formatted, it turns out it was actually that the module was misnamed. According to this post, the updated module has been renamed to '@parse/simple-mailgun-adapter'. Inserting this into the index.js, after ensuring I had ran the npm install --save @parse/simple-mailgun-adapter in my local repo, fixed the issue.

Runeaway3
  • 1,439
  • 1
  • 17
  • 43