Skip to content

Commit

Permalink
Add parse dashboard (BloomBooks#12)
Browse files Browse the repository at this point in the history
Also did some minor cleanup
  • Loading branch information
andrew-polk authored and hatton committed Dec 5, 2016
1 parent 6c0555d commit 7f34534
Show file tree
Hide file tree
Showing 9 changed files with 39 additions and 551 deletions.
20 changes: 8 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,25 +17,14 @@ Here is the full [Parse Server guide](https://github.com/ParsePlatform/parse-ser

1. Give mongodb a blank directory to work with, and run it:

`mongod.exe --dbpath x:\temp\mongodata`
`mongod.exe --dbpath c:\temp\mongodata`

1. Start up this server:

`npm start`

Or, to debug, open bloom-parse-server in vscode, F5 (Debug: Launch via NPM). Note that this sets the masterid to "123", via an environment variable.

To verify that it is running, open a browser to http://localhost:1337/test

1. Run Parse Dashboard:

```
npm install parse-dashboard --global
parse-dashboard --appId myAppId --masterKey "123" --serverURL http://localhost:1337/parse
```
This will respond that it is available at http://0.0.0.0, but actually it is at http://localhost.
1. Setup or update the mongodb Schema

```
Expand All @@ -47,6 +36,13 @@ Here is the full [Parse Server guide](https://github.com/ParsePlatform/parse-ser
and see the tables in the dashboard.
1. Run Parse Dashboard:
Go to [http://localhost:1337/dashboard] (http://localhost:1337/dashboard)
You will be required to log in:
The username is the appId ('myAppId')
The password is the masterKey ('123')
### Sample Queries
Expand Down
12 changes: 0 additions & 12 deletions app.yaml

This file was deleted.

4 changes: 0 additions & 4 deletions cloud/mainOrig.js

This file was deleted.

53 changes: 26 additions & 27 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,27 +1,20 @@
// Example express application adding the parse-server module to expose Parse
// compatible API routes.

var express = require('express');
var ParseServer = require('parse-server').ParseServer;
var ParseDashboard = require('parse-dashboard');
var SimpleSendGridAdapter = require('parse-server-sendgrid-adapter');

var path = require('path');

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({
var serverConfig = {
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 || '',
serverURL: process.env.SERVER_URL || 'http://localhost:1337/parse',
liveQuery: {
classNames: ["Posts", "Comments"] // List of classes to support for query subscriptions
},

//password reset
emailAdapter: SimpleSendGridAdapter({
Expand All @@ -30,37 +23,43 @@ var api = new ParseServer({
}),
publicServerURL: process.env.SERVER_URL || 'http://localhost:1337/parse', // apparently used by password reset emailer
verifyUserEmails:true,
appName:'BloomLibrary.org'
});
appName: process.env.APP_NAME || 'BloomLibrary.org'
};
var api = new ParseServer(serverConfig);
// 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 allowInsecureHTTP = false;
var dashboard = new ParseDashboard({
apps: [
{
appId: serverConfig.appId,
serverURL: serverConfig.serverURL,
masterKey: serverConfig.masterKey,
appName: serverConfig.appName,
production: serverConfig.serverURL.includes('production')
}
],
users: [
{
user: serverConfig.appId,
pass: serverConfig.masterKey
}
]
}, allowInsecureHTTP);

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!');
});

// There will be a test page available on the /test path of your server url
// Remove this before launching your app
app.get('/test', function(req, res) {
res.sendFile(path.join(__dirname, '/public/test.html'));
});
app.use('/dashboard', dashboard);

var port = process.env.PORT || 1337;
var httpServer = require('http').createServer(app);
httpServer.listen(port, function() {
console.log('parse-server-example running on port ' + port + '.');
console.log('bloom-parse-server running on port ' + port + '.');
});

// This will enable the Live Query real-time server
ParseServer.createLiveQueryServer(httpServer);
9 changes: 5 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
{
"name": "parse-server-example",
"name": "bloom-parse-server",
"version": "1.4.0",
"description": "An example Parse API server using the parse-server module",
"description": "Parse server for bloomlibrary.org",
"main": "index.js",
"repository": {
"type": "git",
"url": "https://github.com/ParsePlatform/parse-server-example"
"url": "https://github.com/BloomBooks/bloom-parse-server"
},
"license": "MIT",
"dependencies": {
Expand All @@ -14,7 +14,8 @@
"parse": "~1.8.0",
"parse-server": "~2.2.12",
"parse-server-sendgrid-adapter": "^1.0.0",
"sendgrid": "^4.7.1"
"sendgrid": "^4.7.1",
"parse-dashboard": "^1.0.11"
},
"scripts": {
"start": "node index.js"
Expand Down
Loading

0 comments on commit 7f34534

Please sign in to comment.