From d45d1a9efb96d1d73806d013d2034df5c7b73e06 Mon Sep 17 00:00:00 2001 From: Makan Azarshahy Date: Thu, 29 Mar 2018 10:35:48 -0700 Subject: [PATCH 1/3] Changed names to work with naming convention --- nodeServer/bundlePaths/servicePaths.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/nodeServer/bundlePaths/servicePaths.js b/nodeServer/bundlePaths/servicePaths.js index 686373c..3d80552 100644 --- a/nodeServer/bundlePaths/servicePaths.js +++ b/nodeServer/bundlePaths/servicePaths.js @@ -1,14 +1,14 @@ const servicePaths = { - // about: '', - reservations: 'http://ec2-54-219-137-44.us-west-1.compute.amazonaws.com', - menu: 'http://ec2-54-67-41-26.us-west-1.compute.amazonaws.com', + // SummaryView: '', + // ReservationView: 'http://ec2-54-219-137-44.us-west-1.compute.amazonaws.com', + MenuView: 'http://ec2-54-67-41-26.us-west-1.compute.amazonaws.com', // reviews: '', }; const serviceList = [ - // 'about', - 'reservations', - 'menu', + // 'SummaryView', + // 'ReservationView', + 'MenuView', // 'reviews', ]; From b0a601c40693cbb8c18d4609b96172e1f73d949e Mon Sep 17 00:00:00 2001 From: Makan Azarshahy Date: Thu, 29 Mar 2018 10:36:19 -0700 Subject: [PATCH 2/3] Refactored code to follow naming convention of bundles --- nodeServer/getServerBundles.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nodeServer/getServerBundles.js b/nodeServer/getServerBundles.js index 25f67da..ac2c4ea 100644 --- a/nodeServer/getServerBundles.js +++ b/nodeServer/getServerBundles.js @@ -7,7 +7,7 @@ const { servicePaths, serviceLists } = require('./bundlePaths/servicePaths'); const bundles = []; const getBundle = service => - axios.get(`${servicePaths[service]}/bundle-server.js`); + axios.get(`${servicePaths[service]}/${service}-bundle-server.js`); const writeBundle = service => getBundle(service) From b8fe678784ac4b2c8ca6c2a3836f9727e32c749e Mon Sep 17 00:00:00 2001 From: Makan Azarshahy Date: Thu, 29 Mar 2018 12:13:47 -0700 Subject: [PATCH 3/3] Changed routes to work with different bundles services --- nodeServer/app.js | 5 ++++- nodeServer/bundlePaths/servicePaths.js | 4 ++-- nodeServer/getServerBundles.js | 4 ++-- nodeServer/templates/base.js | 2 +- 4 files changed, 9 insertions(+), 6 deletions(-) diff --git a/nodeServer/app.js b/nodeServer/app.js index b010c37..cf49aec 100644 --- a/nodeServer/app.js +++ b/nodeServer/app.js @@ -5,10 +5,13 @@ const cache = require('./cache'); const app = http.createServer((request, response) => { const { method, url } = request; const [base, restaurantName, service, meal, tag] = url.slice(1).split('/'); + const [component, bundle] = url.slice(1).split('/'); if (method === 'GET') { if (base === '') { serveHtml(response); - } else if (base === 'bundle.js' || base === 'restaurants') { + } else if (bundle.includes('bundle.js')) { + cache(response, `/${bundle}`, component); + } else if (base === 'restaurants') { cache(response, url, service); } else { response.statusCode = 404; diff --git a/nodeServer/bundlePaths/servicePaths.js b/nodeServer/bundlePaths/servicePaths.js index 3d80552..5ea69c4 100644 --- a/nodeServer/bundlePaths/servicePaths.js +++ b/nodeServer/bundlePaths/servicePaths.js @@ -1,14 +1,14 @@ const servicePaths = { // SummaryView: '', // ReservationView: 'http://ec2-54-219-137-44.us-west-1.compute.amazonaws.com', - MenuView: 'http://ec2-54-67-41-26.us-west-1.compute.amazonaws.com', + menu: 'http://ec2-54-67-41-26.us-west-1.compute.amazonaws.com', // reviews: '', }; const serviceList = [ // 'SummaryView', // 'ReservationView', - 'MenuView', + 'menu', // 'reviews', ]; diff --git a/nodeServer/getServerBundles.js b/nodeServer/getServerBundles.js index ac2c4ea..2b58274 100644 --- a/nodeServer/getServerBundles.js +++ b/nodeServer/getServerBundles.js @@ -2,7 +2,7 @@ const axios = require('axios'); const fs = require('fs'); const path = require('path'); -const { servicePaths, serviceLists } = require('./bundlePaths/servicePaths'); +const { servicePaths, serviceList } = require('./bundlePaths/servicePaths'); const bundles = []; @@ -23,7 +23,7 @@ const writeBundle = service => const getAndWriteAllBundles = () => { const list = []; - serviceLists.forEach(service => list.push(writeBundle(service))); + serviceList.forEach(service => list.push(writeBundle(service))); console.log('GET AND WRITE'); return Promise.all(list); }; diff --git a/nodeServer/templates/base.js b/nodeServer/templates/base.js index 5f4077e..609467e 100644 --- a/nodeServer/templates/base.js +++ b/nodeServer/templates/base.js @@ -26,7 +26,7 @@ const createAppBody = (about, reservation, menu, review) => ` `; const createHydrated = (about, reservation, menu, review) => ` - +