1- // Example express application adding the parse-server module to expose Parse
2- // compatible API routes.
3-
4- var express = require ( 'express' ) ;
5- var AzurePushAdapter = require ( 'parse-server-azure-push' ) ;
6- var AzureStorageAdapter = require ( 'parse-server-azure-storage' ) . AzureStorageAdapter ;
7- var ParseServer = require ( 'parse-server' ) . ParseServer ;
8- var databaseUri = process . env . DATABASE_URI || process . env . MONGOLAB_URI ;
9- var mountPath = process . env . PARSE_MOUNT || '/parse' ;
10-
11- if ( ! databaseUri ) {
12- console . log ( 'DATABASE_URI not specified, falling back to localhost.' ) ;
13- }
1+ var azureParseServer = require ( 'parse-server-azure-app' ) ;
2+ var http = require ( 'http' ) ;
143
4+ // Add any custom parse server settings here
155var config = {
16- databaseURI : databaseUri || 'mongodb://localhost:27017/dev' ,
17- cloud : process . env . CLOUD_CODE_MAIN || __dirname + '/cloud/main.js' ,
18- appId : process . env . APP_ID || 'myAppId' ,
19- masterKey : process . env . MASTER_KEY || '' , //Add your master key here. Keep it secret!
20- serverURL : ( process . env . SERVER_URL || 'http://localhost:1337' ) + mountPath , // Don't forget to change to https if needed
21- filesAdapter : _ => {
22- return new AzureStorageAdapter ( process . env . STORAGE_NAME , 'parse' , {
23- accessKey : process . env . STORAGE_KEY ,
24- directAccess : true
25- } ) ;
26- } ,
27- push : AzurePushAdapter
6+ cloud : __dirname + '/cloud/main.js' ,
7+ logsFolder : __dirname + '/logs/' ,
8+ /*
9+ False by default to protect against malicious client attacks.
10+ Enable for development and testing if desired
11+ */
12+ // allowClientClassCreation: false,
13+ // enableAnonymousUsers: false,
14+
15+ /*
16+ Useful settings for developing locally. These are populated via
17+ app settings (environment variables) when hosted in the Azure Web
18+ App deployed by the Parse Server on Managed Azure Services template.
19+ */
20+ // appId: 'my app id',
21+ // masterKey:: 'my master key',
22+ // databaseURI: 'database connection string',
23+ // storage: {
24+ // name: 'storage account name',
25+ // container: 'container to use for files',
26+ // accessKey: 'storage account access key',
27+ // // allow public access to blob storage files
28+ // directAccess: true
29+ // },
30+ // push: {
31+ // ConnectionString: 'notification hub connection string',
32+ // HubName: 'notification hub name'
33+ // }
2834}
2935
30- var api = new ParseServer ( config ) ;
31- // Client-keys like the javascript key or the .NET key are not necessary with parse-server
32- // If you wish you require them, you can set them as options in the initialization above:
33- // javascriptKey, restAPIKey, dotNetKey, clientKey
34-
35- var app = express ( ) ;
36-
37- // Serve the Parse API on the /parse URL prefix
38- app . use ( mountPath , api ) ;
39-
40- // Parse Server plays nicely with the rest of your web routes
41- app . get ( '/' , function ( req , res ) {
42- res . status ( 200 ) . send ( 'I dream of being a web site.' ) ;
43- } ) ;
44-
45- var port = process . env . PORT || 1337 ;
46- app . listen ( port , function ( ) {
47- console . log ( 'parse-server-example running on port ' + port + '.' ) ;
48- } ) ;
36+ var app = azureParseServer ( config ) ;
37+ var httpServer = http . createServer ( app ) ;
38+ httpServer . listen ( process . env . PORT || 1337 ) ;
0 commit comments