|
| 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] |
0 commit comments