Skip to content

Commit

Permalink
Added Parse-server example.
Browse files Browse the repository at this point in the history
  • Loading branch information
jmdobry committed Jan 29, 2016
1 parent c1453b3 commit f419b7a
Show file tree
Hide file tree
Showing 8 changed files with 158 additions and 0 deletions.
1 change: 1 addition & 0 deletions .jshintignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
appengine/bower/public/bower_components/**
appengine/kraken/public/components/**
appengine/parse-server/cloud/main.js
appengine/sails/config/**
appengine/sails/tasks/**
appengine/sails/assets/**
Expand Down
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ __Frameworks__
- Loopback.js - [Source code][loopback_1] | [App Engine Tutorial][loopback_2] | [Live demo][loopback_3] | [Documentation][loopback_4]
- Koa.js - [Source code][koa_1] | [App Engine Tutorial][koa_2] | [Live demo][koa_3] | [Documentation][koa_4]
- Kraken.js - [Source code][kraken_1] | [App Engine Tutorial][kraken_2] | [Live demo][kraken_3] | [Documentation][kraken_4]
- Parse-server - [Source code][parse_1]
- Restify.js - [Source code][restify_1] | [App Engine Tutorial][restify_2] | [Live demo][restify_3] | [Documentation][restify_4]
- Sails.js - [Source code][sails_1] | [App Engine Tutorial][sails_2] | [Live demo][sails_3] | [Documentation][sails_4]

Expand Down Expand Up @@ -190,6 +191,8 @@ See [LICENSE](https://github.com/GoogleCloudPlatform/nodejs-docs-samples/blob/ma
[kraken_3]: http://kraken-dot-nodejs-docs-samples.appspot.com
[kraken_4]: http://krakenjs.com/

[parse_1]: https://github.com/GoogleCloudPlatform/nodejs-docs-samples/blob/master/appengine/parse-server

[restify_1]: https://github.com/GoogleCloudPlatform/nodejs-docs-samples/blob/master/appengine/restify
[restify_2]: https://cloud.google.com/nodejs/resources/frameworks/restify
[restify_3]: http://restify-dot-nodejs-docs-samples.appspot.com
Expand Down
28 changes: 28 additions & 0 deletions appengine/parse-server/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# Parse-server sample for Google App Engine

This sample demonstrates deploying a [Parse-server](https://github.com/ParsePlatform/parse-server)
app to [Google App Engine Managed VMs](https://cloud.google.com/appengine).

## Setup

1. Create a project in the [Google Cloud Platform Console](https://console.cloud.google.com/).
1. [Enable billing](https://console.cloud.google.com/project/_/settings) for your project.
1. Install the [Google Cloud SDK](https://cloud.google.com/sdk/).
1. Setup a MongoDB server:
1. Create a Google Compute Engine virtual machine with [MongoDB pre-installed](https://cloud.google.com/launcher/?q=mongodb).
1. Use [MongoLab](https://mongolab.com/google/) to create a free MongoDB deployment on Google Cloud Platform.

## Running locally

1. `git clone https://github.com/GoogleCloudPlatform/nodejs-docs-samples.git`
1. `cd appengine/parse-server`
1. `npm install`
1. Set the necessary [environment variables](https://github.com/GoogleCloudPlatform/nodejs-docs-samples/blob/master/appengine/parse-server/server.js#L23).
1. `npm start`

## Deploy

1. `gcloud preview app deploy`

Refer to the [appengine/README.md](../README.md) file for more instructions on
running and deploying.
38 changes: 38 additions & 0 deletions appengine/parse-server/app.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# Copyright 2016, Google, Inc.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

runtime: nodejs
vm: true

env_variables:
# Your MongoDB URI, e.g. mongodb://user:password@123.456.78.901:27017/db
DATABASE_URI: mongodb://localhost:27017/dev
# Absolute path to your cloud code main.js file
# CLOUD_PATH: <your-cloud-path>
# App id
# REQUIRED
APP_ID: <your-app-id>
# master key
# REQUIRED
MASTER_KEY: <your-master-key>
# file key
FILE_KEY: <your-file-key>
# Mount path for Parse API
PARSE_MOUNT_PATH: /parse

manual_scaling:
instances: 1

skip_files:
# Don't deploy node_modules folder
- ^(.*/)?.*/node_modules/.*$
17 changes: 17 additions & 0 deletions appengine/parse-server/cloud/main.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// Copyright 2016, Google, Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

Parse.Cloud.define('hello', function(req, res) {
res.success('Hello, world!');
});
20 changes: 20 additions & 0 deletions appengine/parse-server/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"name": "appengine-parse-server",
"description": "Parse-server sample for Google App Engine",
"version": "0.0.1",
"private": true,
"license": "Apache Version 2.0",
"author": "Google Inc.",
"engines": {
"node": "~4.2"
},
"scripts": {
"start": "node server.js",
"monitor": "nodemon server.js",
"deploy": "gcloud preview app deploy"
},
"dependencies": {
"express": "^4.13.4",
"parse-server": "^2.0.0"
}
}
41 changes: 41 additions & 0 deletions appengine/parse-server/server.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
// Copyright 2016, Google, Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

'use strict';

var express = require('express');
var ParseServer = require('parse-server').ParseServer;

var app = express();

var parseServer = new ParseServer({
databaseURI: process.env.DATABASE_URI || 'mongodb://localhost:27017/dev',
cloud: process.env.CLOUD_PATH || __dirname + '/cloud/main.js',
appId: process.env.APP_ID,
masterKey: process.env.MASTER_KEY,
fileKey: process.env.FILE_KEY
});

// Mount the Parse API server middleware to /parse
app.use(process.env.PARSE_MOUNT_PATH || '/parse', parseServer);

app.get('/', function(req, res) {
res.status(200).send('Hello, world!');
});

var server = app.listen(process.env.PORT || 8080, '0.0.0.0', function() {
console.log('App listening at http://%s:%s', server.address().address,
server.address().port);
console.log('Press Ctrl+C to quit.');
});
10 changes: 10 additions & 0 deletions test/appengine/all.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,16 @@ var sampleTests = [
msg: 'Value:',
test: /Value: \d\.\d+/
},
{
dir: 'parse-server',
cmd: 'node',
args: ['server.js'],
msg: 'Hello, world!',
env: {
APP_ID: 'foo',
MASTER_KEY: 'bar'
}
},
{
dir: 'pubsub',
cmd: 'node',
Expand Down

0 comments on commit f419b7a

Please sign in to comment.