Saturday 15 April 2017

Trying to paste data into Parse server - nothing happens?

I newly installed a Parse node.js app on my server. I get the following after running "npm install":

DATABASE_URI not specified, falling back to localhost.

parse-server-example running on port 1339.

I then run the following in a separate terminal:

curl -X POST \ -H "X-Parse-Application-Id: nimbus” \

-H "Content-Type: application/json" \

-d '{"score":1339,”playerName":"Sean Plott","cheatMode":false}' \

http://localhost:1339/parse/classes/GameScore

but I get nothing back - I am supposed to get back this: {"objectId":"fu7t4oWLuW","createdAt":"2016-02-02T18:43:00.659Z"}

After entering the above 3 times, I get back this: Failed to connect to localhost port 1339: Connection refused

And my index.js file:

var databaseUri = process.env.DATABASE_URI || process.env.MONGODB_URI;
if (!databaseUri) {
console.log('DATABASE_URI not specified, falling back to localhost.');
}

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 || 'nimbus',
masterKey: process.env.MASTER_KEY || 'emory', //Add your master key here. Keep it secret!
serverURL: process.env.SERVER_URL || 'http://localhost:1339/parse',  // Don't forget to change to https if needed
liveQuery: {
classNames: ["Posts", "GameScore", "Comments"] // List of classes to support for query subscriptions
}
});
// Client-keys like the javascript key or the .NET key are not necessary with parse-server
// If you wish you require them, you can set them as options in the initialization above:
// javascriptKey, restAPIKey, dotNetKey, clientKey
var app = express();
// Serve static assets from the /public folder
app.use('/public', express.static(path.join(__dirname, '/public')));
// 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 website.  Please star the parse-server repo on GitHub!');
});
var port = process.env.PORT || 1339;
var httpServer = require('http').createServer(app);
httpServer.listen(port, function() {
console.log('parse-server-example running on port ' + port + '.');
});

// This will enable the Live Query real-time server
ParseServer.createLiveQueryServer(httpServer);

What am I doing wrong?



via kupak12

No comments:

Post a Comment