Skip to content

Added Parse-server example. #60

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 29, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
29 changes: 29 additions & 0 deletions appengine/parse-server/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# 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. Here are two possible options:
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. Modify `app.yaml` as needed.
1. `gcloud preview app deploy`

Refer to the [appengine/README.md](../README.md) file for more instructions on
running and deploying.
37 changes: 37 additions & 0 deletions appengine/parse-server/app.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# 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.

# [START app_yaml]
runtime: nodejs
vm: true

env_variables:
# Your MongoDB URI, e.g. mongodb://user:[email protected]: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

skip_files:
# Don't deploy node_modules folder
- ^(.*/)?.*/node_modules/.*$
# [END app_yaml]
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"
}
}
44 changes: 44 additions & 0 deletions appengine/parse-server/server.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
// 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';

// [START app]
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.');
});

// [END app]
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