Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

got frontend stood up

  • Loading branch information...
commit 8ee2622652966aac9e7142b5e47eec5cd91e5709 1 parent 7f3da6b
@JustinBeckwith authored
View
4 frontend/.gitignore
@@ -0,0 +1,4 @@
+node_modules
+keys.json
+iisnode
+instagram-subscriptions.json
View
35 frontend/app.js
@@ -1,35 +0,0 @@
-
-/**
- * Module dependencies.
- */
-
-var express = require('express')
- , routes = require('./routes')
- , user = require('./routes/user')
- , http = require('http')
- , path = require('path');
-
-var app = express();
-
-app.configure(function(){
- app.set('port', process.env.PORT || 3000);
- app.set('views', __dirname + '/views');
- app.set('view engine', 'jade');
- app.use(express.favicon());
- app.use(express.logger('dev'));
- app.use(express.bodyParser());
- app.use(express.methodOverride());
- app.use(app.router);
- app.use(express.static(path.join(__dirname, 'public')));
-});
-
-app.configure('development', function(){
- app.use(express.errorHandler());
-});
-
-app.get('/', routes.index);
-app.get('/users', user.list);
-
-http.createServer(app).listen(app.get('port'), function(){
- console.log("Express server listening on port " + app.get('port'));
-});
View
4 frontend/keys.example.json
@@ -0,0 +1,4 @@
+{
+ "AZURE_SERVICEBUS_NAMESPACE": "NAMESPACE HERE",
+ "AZURE_SERVICEBUS_ACCESS_KEY": "GRIMLOCK NEED SERVICE BUS ACCESS KEY"
+}
View
12 frontend/package.json
@@ -1,12 +1,16 @@
{
- "name": "application-name",
+ "name": "wazstagram-frontend",
"version": "0.0.1",
"private": true,
"scripts": {
- "start": "node app"
+ "start": "node server"
},
"dependencies": {
"express": "3.0.0rc4",
- "jade": "*"
+ "jade": "*",
+ "socket.io": "~0.9.10",
+ "nconf": "~0.6.4",
+ "azure": "~0.6.4",
+ "ejs": "~0.8.3"
}
-}
+}
View
5 frontend/robots.txt
@@ -0,0 +1,5 @@
+
+# This file can be used to affect how search engines and other web site crawlers see your site.
+# For more information, please see http://www.w3.org/TR/html4/appendix/notes.html#h-B.4.1.1
+# WebMatrix 2.0
+
View
15 frontend/routes/home.js
@@ -0,0 +1,15 @@
+
+module.exports = function (app, nconf, serviceBusService) {
+
+ // home page
+ app.get('/', function (req, res) {
+ res.render('index.html');
+ });
+
+ // instagram get
+ app.get('/:city', function (req, res) {
+ console.log(req.params.city);
+ //res.end(req.params.city);
+ res.render('images.html');
+ });
+}
View
8 frontend/routes/index.js
@@ -1,8 +0,0 @@
-
-/*
- * GET home page.
- */
-
-exports.index = function(req, res){
- res.render('index', { title: 'Express' });
-};
View
8 frontend/routes/user.js
@@ -1,8 +0,0 @@
-
-/*
- * GET users listing.
- */
-
-exports.list = function(req, res){
- res.send("respond with a resource");
-};
View
57 frontend/server.js
@@ -0,0 +1,57 @@
+
+/**
+* Module dependencies.
+*/
+
+var express = require('express')
+ , nconf = require('nconf')
+ , azure = require('azure')
+ , http = require('http')
+ , path = require('path');
+
+
+nconf.argv().env().file('keys.json');
+
+var sbNamespace = nconf.get('AZURE_SERVICEBUS_NAMESPACE');
+var sbKey = nconf.get('AZURE_SERVICEBUS_ACCESS_KEY');
+var serviceBusService = azure.createServiceBusService(sbNamespace, sbKey);
+serviceBusService.createTopicIfNotExists('wazages', function (error) {
+ if (!error) {
+ console.log('topic wazages created or exists');
+ } else {
+ console.log('error creating service topic wazages');
+ }
+});
+
+var app = express();
+
+app.configure(function () {
+ app.set('port', process.env.PORT || 3000);
+ app.set('views', __dirname + '/views');
+ app.set('view engine', 'jade');
+ app.engine('html', require('ejs').renderFile);
+ app.use(express.favicon());
+ app.use(express.logger('dev'));
+ app.use(express.bodyParser());
+ app.use(express.methodOverride());
+ app.use(app.router);
+ app.use(express.static(path.join(__dirname, 'public')));
+});
+
+app.configure('development', function () {
+ app.use(express.errorHandler());
+});
+
+require('./routes/home')(app, nconf, serviceBusService);
+
+var server = http.createServer(app).listen(app.get('port'), function () {
+ console.log("Express server listening on port " + app.get('port'));
+});
+
+var io = require('socket.io').listen(server);
+io.sockets.on('connection', function (socket) {
+ socket.emit('news', { hello: 'world' });
+ socket.on('my other event', function (data) {
+ console.log(data);
+ });
+});
View
18 frontend/views/images.html
@@ -0,0 +1,18 @@
+<!DOCTYPE html>
+<html lang="en">
+ <head>
+ <meta charset="utf-8" />
+ <title></title>
+ <script src="/socket.io/socket.io.js"></script>
+ <script>
+ var socket = io.connect();
+ socket.on('news', function (data) {
+ console.log(data);
+ socket.emit('my other event', { my: 'data' });
+ });
+ </script>
+ </head>
+ <body>
+
+ </body>
+</html>
View
17 frontend/views/index.html
@@ -0,0 +1,17 @@
+<!DOCTYPE html>
+
+<html lang="en">
+ <head>
+ <meta charset="utf-8" />
+ <title></title>
+ </head>
+ <body>
+ <a href="/seattle">Seattle</a>
+ <a href="/new-york">New York</a>
+ <a href="/los-angeles">Los Angeles</a>
+ <a href="/pittsburgh">Pittsburgh</a>
+ <a href="/san-francisco">San Francisco</a>
+ <a href="/washington-dc">Washington DC</a>
+ <a href="/rome">Rome</a>
+ </body>
+</html>
View
5 frontend/views/index.jade
@@ -1,5 +0,0 @@
-extends layout
-
-block content
- h1= title
- p Welcome to #{title}
View
7 frontend/views/layout.jade
@@ -1,7 +0,0 @@
-doctype 5
-html
- head
- title= title
- link(rel='stylesheet', href='/stylesheets/style.css')
- body
- block content
View
66 frontend/web.config
@@ -0,0 +1,66 @@
+<configuration>
+ <system.webServer>
+
+ <handlers>
+ <!-- indicates that the server.js file is a node.js application to be handled by the iisnode module -->
+ <add name="iisnode" path="server.js" verb="*" modules="iisnode" />
+ </handlers>
+
+ <rewrite>
+ <rules>
+ <!-- Don't interfere with requests for logs -->
+ <rule name="LogFile" patternSyntax="ECMAScript" stopProcessing="true">
+ <match url="^[a-zA-Z0-9_\-]+\.js\.logs\/\d+\.txt$" />
+ </rule>
+
+ <!-- Don't interfere with requests for node-inspector debugging -->
+ <rule name="NodeInspector" patternSyntax="ECMAScript" stopProcessing="true">
+ <match url="^server.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 application entry point -->
+ <rule name="DynamicContent">
+ <conditions>
+ <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="True" />
+ </conditions>
+ <action type="Rewrite" url="server.js" />
+ </rule>
+ </rules>
+ </rewrite>
+
+ <!-- You can control how Node is hosted within IIS using the following options -->
+ <!--<iisnode
+ node_env="%node_env%"
+ nodeProcessCountPerApplication="1"
+ maxConcurrentRequestsPerProcess="1024"
+ maxNamedPipeConnectionRetry="3"
+ namedPipeConnectionRetryDelay="2000"
+ maxNamedPipeConnectionPoolSize="512"
+ maxNamedPipePooledConnectionAge="30000"
+ asyncCompletionThreadCount="0"
+ initialRequestBufferSize="4096"
+ maxRequestBufferSize="65536"
+ watchedFiles="*.js"
+ uncFileChangesPollingInterval="5000"
+ gracefulShutdownTimeout="60000"
+ loggingEnabled="true"
+ logDirectoryNameSuffix="logs"
+ debuggingEnabled="true"
+ debuggerPortRange="5058-6058"
+ debuggerPathSegment="debug"
+ maxLogFileSizeInKB="128"
+ appendToExistingLog="false"
+ logFileFlushInterval="5000"
+ devErrorsEnabled="true"
+ flushResponse="false"
+ enableXFF="false"
+ promoteServerVars=""
+ />-->
+ <iisnode watchedFiles="*.js;node_modules\*;routes\*.js;views\*.jade;middleware\*.js;iisnode.yml"/>
+ </system.webServer>
+</configuration>
Please sign in to comment.
Something went wrong with that request. Please try again.