Skip to content

Commit 935abc9

Browse files
committed
Added Parse-server example.
1 parent c1453b3 commit 935abc9

File tree

8 files changed

+161
-0
lines changed

8 files changed

+161
-0
lines changed

.jshintignore

+1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
appengine/bower/public/bower_components/**
22
appengine/kraken/public/components/**
3+
appengine/parse-server/cloud/main.js
34
appengine/sails/config/**
45
appengine/sails/tasks/**
56
appengine/sails/assets/**

README.md

+3
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ __Frameworks__
3737
- Loopback.js - [Source code][loopback_1] | [App Engine Tutorial][loopback_2] | [Live demo][loopback_3] | [Documentation][loopback_4]
3838
- Koa.js - [Source code][koa_1] | [App Engine Tutorial][koa_2] | [Live demo][koa_3] | [Documentation][koa_4]
3939
- Kraken.js - [Source code][kraken_1] | [App Engine Tutorial][kraken_2] | [Live demo][kraken_3] | [Documentation][kraken_4]
40+
- Parse-server - [Source code][parse_1]
4041
- Restify.js - [Source code][restify_1] | [App Engine Tutorial][restify_2] | [Live demo][restify_3] | [Documentation][restify_4]
4142
- Sails.js - [Source code][sails_1] | [App Engine Tutorial][sails_2] | [Live demo][sails_3] | [Documentation][sails_4]
4243

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

194+
[parse_1]: https://github.com/GoogleCloudPlatform/nodejs-docs-samples/blob/master/appengine/parse-server
195+
193196
[restify_1]: https://github.com/GoogleCloudPlatform/nodejs-docs-samples/blob/master/appengine/restify
194197
[restify_2]: https://cloud.google.com/nodejs/resources/frameworks/restify
195198
[restify_3]: http://restify-dot-nodejs-docs-samples.appspot.com

appengine/parse-server/README.md

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# Parse-server sample for Google App Engine
2+
3+
This sample demonstrates deploying a [Parse-server](https://github.com/ParsePlatform/parse-server)
4+
app to [Google App Engine Managed VMs](https://cloud.google.com/appengine).
5+
6+
## Setup
7+
8+
1. Create a project in the [Google Cloud Platform Console](https://console.cloud.google.com/).
9+
1. [Enable billing](https://console.cloud.google.com/project/_/settings) for your project.
10+
1. Install the [Google Cloud SDK](https://cloud.google.com/sdk/).
11+
1. Setup a MongoDB server. Here are two possible options:
12+
1. Create a Google Compute Engine virtual machine with [MongoDB pre-installed](https://cloud.google.com/launcher/?q=mongodb).
13+
1. Use [MongoLab](https://mongolab.com/google/) to create a free MongoDB deployment on Google Cloud Platform.
14+
15+
## Running locally
16+
17+
1. `git clone https://github.com/GoogleCloudPlatform/nodejs-docs-samples.git`
18+
1. `cd appengine/parse-server`
19+
1. `npm install`
20+
1. Set the necessary [environment variables](https://github.com/GoogleCloudPlatform/nodejs-docs-samples/blob/master/appengine/parse-server/server.js#L23).
21+
1. `npm start`
22+
23+
## Deploy
24+
25+
1. Modify `app.yaml` as needed.
26+
1. `gcloud preview app deploy`
27+
28+
Refer to the [appengine/README.md](../README.md) file for more instructions on
29+
running and deploying.

appengine/parse-server/app.yaml

+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# Copyright 2016, Google, Inc.
2+
# Licensed under the Apache License, Version 2.0 (the "License");
3+
# you may not use this file except in compliance with the License.
4+
# You may obtain a copy of the License at
5+
#
6+
# http://www.apache.org/licenses/LICENSE-2.0
7+
#
8+
# Unless required by applicable law or agreed to in writing, software
9+
# distributed under the License is distributed on an "AS IS" BASIS,
10+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11+
# See the License for the specific language governing permissions and
12+
# limitations under the License.
13+
14+
# [START app_yaml]
15+
runtime: nodejs
16+
vm: true
17+
18+
env_variables:
19+
# Your MongoDB URI, e.g. mongodb://user:[email protected]:27017/db
20+
DATABASE_URI: mongodb://localhost:27017/dev
21+
# Absolute path to your cloud code main.js file
22+
# CLOUD_PATH: <your-cloud-path>
23+
# App id
24+
# REQUIRED
25+
APP_ID: <your-app-id>
26+
# master key
27+
# REQUIRED
28+
MASTER_KEY: <your-master-key>
29+
# file key
30+
FILE_KEY: <your-file-key>
31+
# Mount path for Parse API
32+
PARSE_MOUNT_PATH: /parse
33+
34+
skip_files:
35+
# Don't deploy node_modules folder
36+
- ^(.*/)?.*/node_modules/.*$
37+
# [END app_yaml]

appengine/parse-server/cloud/main.js

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
// Copyright 2016, Google, Inc.
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
Parse.Cloud.define('hello', function(req, res) {
16+
res.success('Hello, world!');
17+
});

appengine/parse-server/package.json

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
{
2+
"name": "appengine-parse-server",
3+
"description": "Parse-server sample for Google App Engine",
4+
"version": "0.0.1",
5+
"private": true,
6+
"license": "Apache Version 2.0",
7+
"author": "Google Inc.",
8+
"engines": {
9+
"node": "~4.2"
10+
},
11+
"scripts": {
12+
"start": "node server.js",
13+
"monitor": "nodemon server.js",
14+
"deploy": "gcloud preview app deploy"
15+
},
16+
"dependencies": {
17+
"express": "^4.13.4",
18+
"parse-server": "^2.0.0"
19+
}
20+
}

appengine/parse-server/server.js

+44
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
// Copyright 2016, Google, Inc.
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
'use strict';
16+
17+
// [START app]
18+
var express = require('express');
19+
var ParseServer = require('parse-server').ParseServer;
20+
21+
var app = express();
22+
23+
var parseServer = new ParseServer({
24+
databaseURI: process.env.DATABASE_URI || 'mongodb://localhost:27017/dev',
25+
cloud: process.env.CLOUD_PATH || __dirname + '/cloud/main.js',
26+
appId: process.env.APP_ID,
27+
masterKey: process.env.MASTER_KEY,
28+
fileKey: process.env.FILE_KEY
29+
});
30+
31+
// Mount the Parse API server middleware to /parse
32+
app.use(process.env.PARSE_MOUNT_PATH || '/parse', parseServer);
33+
34+
app.get('/', function(req, res) {
35+
res.status(200).send('Hello, world!');
36+
});
37+
38+
var server = app.listen(process.env.PORT || 8080, '0.0.0.0', function() {
39+
console.log('App listening at http://%s:%s', server.address().address,
40+
server.address().port);
41+
console.log('Press Ctrl+C to quit.');
42+
});
43+
44+
// [END app]

test/appengine/all.test.js

+10
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,16 @@ var sampleTests = [
138138
msg: 'Value:',
139139
test: /Value: \d\.\d+/
140140
},
141+
{
142+
dir: 'parse-server',
143+
cmd: 'node',
144+
args: ['server.js'],
145+
msg: 'Hello, world!',
146+
env: {
147+
APP_ID: 'foo',
148+
MASTER_KEY: 'bar'
149+
}
150+
},
141151
{
142152
dir: 'pubsub',
143153
cmd: 'node',

0 commit comments

Comments
 (0)