Skip to content
This repository was archived by the owner on Jul 19, 2024. It is now read-only.

Commit 9feee4f

Browse files
author
Matt Mason
committed
Using azure app module
1 parent 4d1a07d commit 9feee4f

File tree

3 files changed

+39
-54
lines changed

3 files changed

+39
-54
lines changed

index.js

Lines changed: 34 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1,48 +1,38 @@
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
155
var 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);

node_modules.zip

4.57 MB
Binary file not shown.

package.json

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,15 @@
11
{
2-
"name": "parse-server-example",
3-
"version": "1.2.0",
4-
"description": "An example Parse API server using the parse-server module",
2+
"name": "parse-server-azure-managed",
3+
"version": "1.0.0",
4+
"description": "Parse Server on Azure Managed Services",
55
"main": "index.js",
66
"repository": {
77
"type": "git",
8-
"url": "https://github.com/ParsePlatform/parse-server-example"
8+
"url": "https://github.com/mamaso/parse-server-example"
99
},
1010
"license": "MIT",
1111
"dependencies": {
12-
"express": "~4.2.x",
13-
"kerberos": "~0.0.x",
14-
"parse": "~1.6.12",
15-
"parse-server": "2.1.4",
16-
"parse-server-azure-push": "0.0.3",
17-
"parse-server-azure-storage": "0.3.0"
12+
"parse-server-azure-app": "0.0.0"
1813
},
1914
"scripts": {
2015
"start": "node index.js"

0 commit comments

Comments
 (0)