I am able to run parse-server on Amazon Elastic Beanstalk and run locally the parse-dashboard with local NodeJS however Cloud Code logs does not show up even if in the settings it is configured:
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!
fileKey: process.env.FILE_KEY || '', // Add the file key to provide access to files already hosted on Parse
serverURL: process.env.SERVER_URL || 'http://localhost:1337/parse', // Don't forget to change to https if needed
liveQuery: {
classNames: ["Posts", "Comments"] // List of classes to support for query subscriptions
}
});
What could be missing in the configuration?
Here's the code that I am expecting to log:
Parse.Cloud.define('hello', function(req, res) {
console.log('hello method called');
res.success('Hi');
});
I can see from my sample website that the method return the correct response but logs does not show in the parse-dashboard.
Its nothing that you can do in the configuration. The CloudCode is currently not meant to be shown in the Parse Dashboard but Parse Community is working on it. See and follow that issue (https://github.com/ParsePlatform/parse-server/issues/895) and as soon its closed you might be able to view the cloude code on Parse Dashboard.
Related
I have a parse server running in clustering, everything works perfectly but in the last days I have had to add live queries, just activate it in the configuration doesn't work very well, because the event "create" is triggered only few times (while not in clustering it doesn't miss one).
From parse documentation it's suggested to use redis, and here is my problem: I don't understand how the parse's db is passed to redis' db to work properly.
Could please someone just put me on right path?
When you configure your ParseServer, there's an option to include the URL for the Redis server and set the class names for which you want to enable Live Queries:
liveQuery: {
classNames: ['_User', 'Map'],
redisURL: 'redis://localhost:6379'
}
Full setup:
var api = new ParseServer({
databaseURI: databaseUri || 'mongodb://IP:PORT/PATH',
cloud: process.env.CLOUD_CODE_MAIN || __dirname + '/cloud/main.js',
appId: process.env.APP_ID || 'AppID',
masterKey: process.env.MASTER_KEY || 'MasterKey', //Add your master key here. Keep it secret!
//javascriptKey: process.env.JAVASCRIPT_KEY || '',
serverURL: process.env.SERVER_URL || 'http://IP:PORT/parse', // Don't forget to change to https if needed
liveQuery: {
classNames: ['ExampleClass'], // Add Class names here
redisURL: 'redis://REDIS_IP:REDIS_PORT'
},
});
var app = express();
var port = process.env.PORT || 1111;
var httpServer = require('http').createServer(app);
httpServer.listen(port, function() {
console.log('App on port ' + port + '.');
});
// This will enable the Live Query real-time server
ParseServer.createLiveQueryServer(httpServer, {
redisURL: 'redis://REDIS_IP:REDIS_PORT'
});
I'm trying to get the parse-server password reset functionality working, but no success so far. This is my setup:
var api = new ParseServer({
databaseURI: process.env.DATABASE_URI || process.env.MONGOLAB_IVORY_URI,
cloud: process.env.CLOUD_CODE_MAIN || __dirname + '/cloud/main.js',
appId: process.env.APP_ID || 'APP_NAME',
clientKey: process.env.CLIENT_KEY || 'xxxx',
masterKey: process.env.MASTER_KEY || '',
serverURL: process.env.SERVER_URL || 'https://APP.herokuapp.com/parse',
appName : 'APP_NAME',
verifyUserEmails: true,
publicServerURL: 'https://APP.herokuapp.com/parse',
emailAdapter: {
module: 'parse-server-simple-mailgun-adapter',
options: {
fromAddress: 'From Name <from#email.com>',
domain: 'https://api.mailgun.net/v3/***MY_DOMAIN***/messages',
apiKey: 'key-xxxxxxxxxx',
}
}
});
The iOS Parse SDK simply says the email is succesfully sent, but nothing arrives. Also the Mailgun logs show no sign of activity. I have tested this Mailgun setup with curl and that worked just fine.
I tried both https://api.mailgun.net/v3/MY_DOMAIN/messages and https://api.mailgun.net/v3/MY_DOMAIN
Any clue what's wrong with my setup?
Or how I can troubleshoot this remotely running Parse setup?
Ok I managed to solve it after hours of digging.
As it turns out the parse-simple-mailgun-adapter does not handle invalid Mailgun URLs.
Instead of providing https://api.mailgun.net/v3/MY_DOMAIN, I should have provided just MY_DOMAIN. Appearantly the adapter will construct the url.
this is the main config from index.js in ParseServer code:
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 || 'myMasterKey', //Add your master key here. Keep it secret!
serverURL: process.env.SERVER_URL || 'http://localhost:1337', // Don't forget to change to https if needed
liveQuery: {
classNames: ["Posts", "Comments"] // List of classes to support for query subscriptions
}
As I understand it, I do not have to change any of these values. No need to hardcode my keys since I can make use of Heroku config vars:
However, I must be doing something wrong since launching my Heroku app results in a generic error:
I want to avoid the hardcoding-in-code option. Any ideas?
Heroku app logs:
I am using the Parse Server Simple Mailgun Adapter, and my Parse Server is working perfectly on Heroku. I am new to node.js and Express, but I installed the adapter on the root of the Parse Server via:
npm i parse-server-simple-mailgun-adapter
This created a node_modules folder and essentially cloned the Github repository for the Mailgun Adapter. My index.js Parse Server configuration looks like:
var api = new ParseServer({
verifyUserEmails: true,
databaseURI: databaseUri || 'mongodb://DATABASE',
cloud: process.env.CLOUD_CODE_MAIN || __dirname + '/cloud/main.js',
appId: process.env.APP_ID || 'APPID',
masterKey: process.env.MASTER_KEY || 'MASTERKEY', //Add your master key here. Keep it secret!
serverURL: process.env.SERVER_URL || 'https://SERVER/parse', // Don't forget to change to https if needed
publicServerURL: 'https://SERVER/parse',
fileKey: process.env.FILE_KEY || 'FILEKEY',
push: {
ios: [
{
pfx: 'FILE.p12', // Dev PFX or P12
bundleId: 'BUNDLE',
production: false // Dev
},
{
pfx: 'FILE.p12', // Prod PFX or P12
bundleId: 'BUNDLE',
production: true // Prod
}
]
},
emailAdapter: {
module: 'parse-server-simple-mailgun-adapter',
options: {
fromAddress: 'EMAIL#DOMAIN',
domain: 'DOMAIN',
apiKey: 'KEY',
}
},
liveQuery: {
classNames: ["Posts", "Comments"] // List of classes to support for query subscriptions
}
});
The server works perfectly when commenting out the verifyUserEmails key. With it, the server will not work. The Mailgun adapter does not work regardless. Any help would be greatly appreciated. Thanks!
Did you set up the email adapter?
Take a look at : https://github.com/ParsePlatform/parse-server
Email verification and password reset
Verifying user email addresses and enabling password reset via email requries an email adapter. As part of the parse-server package we provide an adapter for sending email through Mailgun. To use it, sign up for Mailgun, and add this to your initialization code:
var server = ParseServer({
...otherOptions,
// Enable email verification
verifyUserEmails: true,
// The public URL of your app.
// This will appear in the link that is used to verify email addresses and reset passwords.
// Set the mount path as it is in serverURL
publicServerURL: 'https://example.com/parse',
// Your apps name. This will appear in the subject and body of the emails that are sent.
appName: 'Parse App',
// The email adapter
emailAdapter: {
module: 'parse-server-simple-mailgun-adapter',
options: {
// The address that your emails come from
fromAddress: 'parse#example.com',
// Your domain from mailgun.com
domain: 'example.com',
// Your API key from mailgun.com
apiKey: 'key-mykey',
}
}
});
You can also use other email adapters contributed by the community such as parse-server-sendgrid-adapter or parse-server-mandrill-adapter.
OR
Create your own in cloud code using mailgun-js
https://www.npmjs.com/package/mailgun-js
var api_key = '[SECRET_API_KEY]';
var domain = '[DOMAIN_HERE]';
var mailgun = require('mailgun-js')({apiKey: api_key, domain: domain});
Parse.Cloud.define('testemail', function(req, res) {
var data = {
from: 'Excited User <me#samples.mailgun.org>',
to: 'foo#bar.com',
subject: 'Hello',
text: 'Testing some Mailgun awesomness!'
};
mailgun.messages().send(data, function (error, body) {
console.log(body);
});
res.success('Email Sent!');
});
The real reason why this happens is because you need to include the appName in your server initialization (this drove me crazy for hours)
appName: 'yourAppName',
Has nobody gotten Unity SDK to work w/ self hosted Parse deployment?
If I use the prescribed code, that looks like this:
ParseClient.Initialize(new ParseClient.Configuration {
ApplicationId = "abc123",
Server = "http://exampe.ip.com/parse/"
});
i get a callstack that looks like this:
>
NullReferenceException: Object reference not set to an instance of an object
UnityEngine.WWW.FlattenedHeadersFrom (System.Collections.Generic.Dictionary`2 headers) (at C:/buildslave/unity/build/Runtime/Export/WWW.cs:118)
UnityEngine.WWW..ctor (System.String url, System.Byte[] postData, System.Collections.Generic.Dictionary`2 headers) (at C:/buildslave/unity/build/artifacts/generated/common/runtime/UtilsBindings.gen.cs:129)
Parse.Internal.HttpClient.GenerateWWWInstance (System.String uri, System.Byte[] bytes, System.Collections.Hashtable headerTable)
Parse.Internal.HttpClient+<>c__DisplayClass10+<>c__DisplayClass16.<ExecuteAsync>b__9 ()
Parse.PlatformHooks+<RunDispatcher>d__2e.MoveNext ()
UnityEngine.Debug:LogException(Exception)
Parse.<RunDispatcher>d__2e:MoveNext()
What am I missing?
I've debugged this and its due to a null value for the windowskey (aka ClientKey). Alter your initialization code to be the following and it should work:
ParseClient.Initialize(new ParseClient.Configuration {
ApplicationId = "abc123",
Server = "http://exampe.ip.com/parse/",
WindowsKey = '' //<== specify an empty string
});
in index.js:
....
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 || 'myMasterKey', //Add your master key here. Keep it secret!
serverURL: process.env.SERVER_URL || 'http://localhost:1337/parse', // Don't forget to change to https if needed
clientKey: '', <=== possibly not needed, just to be sure
liveQuery: {
classNames: ["Scores", "Posts", "Comments"] // List of classes to support for query subscriptions
}
});