-
Notifications
You must be signed in to change notification settings - Fork 2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
158 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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/.*$ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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!'); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.'); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters