diff --git a/package.json b/package.json index b03c67b..7ac0e2a 100644 --- a/package.json +++ b/package.json @@ -3,7 +3,9 @@ "version": "1.0.0", "description": "", "main": "index.js", - "engines": { "node": ">=14.15.0"}, + "engines": { + "node": ">=14.15.0" + }, "scripts": { "test": "echo \"Error: no test specified\" && exit 1", "start": "node server", diff --git a/public/index.html b/public/index.html index 4ef0445..b23b0f2 100644 --- a/public/index.html +++ b/public/index.html @@ -7,13 +7,15 @@ -
-
+
+
+
+
-
+
- + \ No newline at end of file diff --git a/server/config/services.js b/server/config/services.js index 1282711..175aa8b 100644 --- a/server/config/services.js +++ b/server/config/services.js @@ -42,23 +42,23 @@ module.exports = { service1: { - api: 'FIX_ME', + api: '/*/:id/photos', url: 'http://localhost:3001', - bundle: 'app.js', + bundle: '/photos/:id/bundle.js' }, service2: { - api: 'FIX_ME', - url: 'http://localhost:3002', - bundle: 'app.js', + api: '/*/:id/checkout', + url: 'http://localhost:3005', + bundle: '/checkout/:id/bundle.js', }, service3: { - api: 'FIX_ME', + api: '/ctl', url: 'http://localhost:3003', - bundle: 'app.js', + bundle: 'bundle.js', }, service4: { - api: 'FIX_ME', - url: 'http://localhost:3004', - bundle: 'app.js', - }, + api: '/*/:id/reviews', + url: 'http://localhost:8000', + bundle: '/reviews/:id/bundle.js' + } }; diff --git a/server/index.js b/server/index.js index b6a8d34..8c44f1d 100644 --- a/server/index.js +++ b/server/index.js @@ -7,5 +7,5 @@ const server = require('./server.js'); const PORT = 3000 || process.env.PORT; server.listen(PORT, () => { - console.log(`Server running on localhost:${PORT}`); + console.log(`Server running on http://localhost:${PORT}/products/1`); }); diff --git a/server/router/api.js b/server/router/api.js index cdedd69..de39938 100644 --- a/server/router/api.js +++ b/server/router/api.js @@ -1,7 +1,7 @@ const { Router } = require('express'); const { createProxyMiddleware } = require('http-proxy-middleware'); const { - service1, service2, service3, service4, + service1, service2, service3, service4 } = require('../config/services.js'); const router = Router(); diff --git a/server/router/bundles.js b/server/router/bundles.js index 8d40c99..52494cd 100644 --- a/server/router/bundles.js +++ b/server/router/bundles.js @@ -1,7 +1,7 @@ const { Router } = require('express'); const { createProxyMiddleware } = require('http-proxy-middleware'); const { - service1, service2, service3, service4, + service1, service2, service3, service4 } = require('../config/services.js'); const router = Router(); @@ -9,7 +9,7 @@ const router = Router(); router.use('/service1.js', createProxyMiddleware({ target: service1.url, pathRewrite: { - '^/bundles/service1.js': service1.bundle, + '^.*': service1.bundle, }, changeOrigin: true, })); @@ -17,7 +17,7 @@ router.use('/service1.js', createProxyMiddleware({ router.use('/service2.js', createProxyMiddleware({ target: service2.url, pathRewrite: { - '^/bundles/service2.js': service2.bundle, + '^.*': service2.bundle, }, changeOrigin: true, })); @@ -25,7 +25,7 @@ router.use('/service2.js', createProxyMiddleware({ router.use('/service3.js', createProxyMiddleware({ target: service3.url, pathRewrite: { - '^/bundles/service3.js': service3.bundle, + '^.*': service3.bundle, }, changeOrigin: true, })); @@ -33,7 +33,7 @@ router.use('/service3.js', createProxyMiddleware({ router.use('/service4.js', createProxyMiddleware({ target: service4.url, pathRewrite: { - '^/bundles/service4.js': service4.bundle, + '^.*': service4.bundle, }, changeOrigin: true, })); diff --git a/server/server.js b/server/server.js index d2b7f5e..cf65bfb 100644 --- a/server/server.js +++ b/server/server.js @@ -7,11 +7,12 @@ const PUBLIC_DIR = path.resolve(__dirname, '..', 'public'); const app = express(); app.use(morgan('dev')); -app.use(express.static(PUBLIC_DIR)); +app.use('/products/:id', express.static(PUBLIC_DIR)); +// app.use('/:id', express.static(PUBLIC_DIR)); // Handling asset requests for webpack bundles by passing off requests to the bundles router -app.use('/bundles', router.bundles); +app.use('/products/:id/bundles', router.bundles); // Handling AJAX requests to the API by passing off requests to the api router -app.use('/api', router.api); +app.use('/', router.api); module.exports = app;