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

Commit

Permalink
Using parse-server-azure-configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
Matt Mason committed May 10, 2016
1 parent ce8bfca commit a143fbc
Show file tree
Hide file tree
Showing 7 changed files with 97 additions and 36 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
This is the app that is deployed by the 'Parse Server on managed Azure services' package in the Azure marketplace.

In order to speed deployment (and deal with kerberos native module), it uses prepackaged node_modules. Steps are as follows:
1. install node@4.3.0, npm@3.7.3
1. install node@4.3.0, npm@^3.8.3
2. run package.ps1
* installs production modules
* cleans the modules of unnecessary files / folders
Expand Down
6 changes: 6 additions & 0 deletions config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
module.exports = {
server: {},
dashboard: {},
storage: {},
push: {}
}
51 changes: 18 additions & 33 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,38 +1,23 @@
var azureParseServer = require('parse-server-azure-app');
var express = require('express');
var ParseServer = require('parse-server').ParseServer;
var ParseDashboard = require('parse-dashboard');
var parseServerConfig = require('parse-server-azure-config');
var http = require('http');
var url = require('url');

// Add any custom parse server settings here
var config = {
cloud: __dirname + '/cloud/main.js',
logsFolder: __dirname + '/logs/',
/*
False by default to protect against malicious client attacks.
Enable for development and testing if desired
*/
// allowClientClassCreation: false,
// enableAnonymousUsers: false,
var config = parseServerConfig(__dirname, {
defaults: 'config.js',
secrets: 'secrets.js'
});

/*
Useful settings for developing locally. These are populated via
app settings (environment variables) when hosted in the Azure Web
App deployed by the Parse Server on Managed Azure Services template.
*/
// appId: 'my app id',
// masterKey:: 'my master key',
// databaseURI: 'database connection string',
// storage: {
// name: 'storage account name',
// container: 'container to use for files',
// accessKey: 'storage account access key',
// // allow public access to blob storage files
// directAccess: true
// },
// push: {
// ConnectionString: 'notification hub connection string',
// HubName: 'notification hub name'
// }
}
// Modify config as necessary before initializing parse server & dashboard

var app = express();
app.use('/public', express.static(__dirname + '/public'));
app.use('/parse', new ParseServer(config.server));
app.use('/parse-dashboard', ParseDashboard(config.dashboard));

var app = azureParseServer(config);
var httpServer = http.createServer(app);
httpServer.listen(process.env.PORT || 1337);
httpServer.listen(process.env.PORT || url.parse(config.server.serverURL).port, function () {
console.log(`Parse Server running at ${config.server.serverURL}`);
});
Binary file modified node_modules.zip
Binary file not shown.
6 changes: 4 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,10 @@
},
"license": "MIT",
"dependencies": {
"parse-server-azure-app": "0.0.0",
"parse-server": "^2.2.7"
"express": "^4.13.4",
"parse-server": "^2.2.8",
"parse-dashboard": "^1.0.11",
"parse-server-azure-config": "^0.0.1"
},
"scripts": {
"start": "node index.js"
Expand Down
6 changes: 6 additions & 0 deletions secrets.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
module.exports = {
server: {},
dashboard: {},
storage: { accessKey: 'access' },
push: {}
}
62 changes: 62 additions & 0 deletions web.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
This configuration file is required if iisnode is used to run node processes behind
IIS or IIS Express. For more information, visit:
https://github.com/tjanczuk/iisnode/blob/master/src/samples/configuration/web.config
-->

<configuration>
<system.webServer>
<!-- Visit http://blogs.msdn.com/b/windowsazure/archive/2013/11/14/introduction-to-websockets-on-windows-azure-web-sites.aspx for more information on WebSocket support -->
<webSocket enabled="false" />
<handlers>
<!-- Indicates that the server.js file is a node.js site to be handled by the iisnode module -->
<add name="iisnode" path="index.js" verb="*" modules="iisnode"/>
</handlers>
<rewrite>
<rules>
<!-- Do not interfere with requests for node-inspector debugging -->
<rule name="NodeInspector" patternSyntax="ECMAScript" stopProcessing="true">
<match url="^index.js\/debug[\/]?" />
</rule>

<!-- First we consider whether the incoming URL matches a physical file in the /public folder -->
<rule name="StaticContent">
<action type="Rewrite" url="public{REQUEST_URI}"/>
</rule>

<!-- All other URLs are mapped to the node.js site entry point -->
<rule name="DynamicContent">
<conditions>
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="True"/>
</conditions>
<action type="Rewrite" url="index.js"/>
</rule>
</rules>
</rewrite>

<!-- 'bin' directory has no special meaning in node.js and apps can be placed in it -->
<security>
<requestFiltering>
<hiddenSegments>
<remove segment="bin"/>
</hiddenSegments>
</requestFiltering>
</security>

<!-- Make sure error responses are left untouched -->
<httpErrors existingResponse="PassThrough" />

<!--
You can control how Node is hosted within IIS using the following options:
* watchedFiles: semi-colon separated list of files that will be watched for changes to restart the server
* node_env: will be propagated to node as NODE_ENV environment variable
* debuggingEnabled - controls whether the built-in debugger is enabled
See https://github.com/tjanczuk/iisnode/blob/master/src/samples/configuration/web.config for a full list of options
-->
<!--<iisnode watchedFiles="web.config;*.js"/>-->
<iisnode watchedFiles="web.config;*.js;cloud\*.js"
</system.webServer>
</configuration>

0 comments on commit a143fbc

Please sign in to comment.