diff --git a/.env b/.env index 0384b8d..8e88ef1 100644 --- a/.env +++ b/.env @@ -2,10 +2,10 @@ # Add this file to .gitignore when using secret data # Docker Compose environment -POSTGRES_PASSWORD = demopsw +POSTGRES_PASSWORD = postgres # Connection strings -POSTGRES_URL = postgres://postgres:demopsw@postgres:5432/microservices +POSTGRES_URL = postgres://postgres:postgres@postgres:5432/microservices RABBIT_URL = amqp://guest:guest@rabbitmq:5672 SERVER_ADDR = 0.0.0.0:8080 diff --git a/README.md b/README.md index 2f1a418..9938451 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ A basic example of microservice architecture which demonstrates communication between a few loosely coupled services. This includes messages between a server terminal and a web user interface with a database service in the middle. -Written in Go, this mainly showcases the exchange of information using RabbitMQ—between backend services—and WebSocket—between frontend and backend. +Written in Go, this mainly showcases the exchange of information using RabbitMQ—between back end services—and WebSocket—between front end and back end. The services are built using Docker which includes a multistage build example. The whole application is served with Docker Compose. @@ -28,7 +28,7 @@ docker attach microservices_backend ### Database -To inspect the database, launch a new container that will connect to our Postgres database. Then enter the password `demopsw` (see the `.env` file). +To inspect the database, launch a new container that will connect to our Postgres database. Then enter the password `postgres` (see the `.env` file). ```bash docker run -it --rm --network microservices_network postgres:13-alpine psql -h postgres -U postgres @@ -40,3 +40,7 @@ Select everything from the messages table: \c microservices select * from messages; ``` + +### RabbitMQ management + +The RabbitMQ management plugin is accessible by visiting `localhost:15672` with `guest` as both username and password. diff --git a/bootstrap/index.html b/bootstrap/index.html new file mode 100644 index 0000000..3d3e3ab --- /dev/null +++ b/bootstrap/index.html @@ -0,0 +1,40 @@ + + + + Microservices + + + + + +
+
+
+
+
+
+
+ + +
+
+
+
+
+
+
+
+ + + +
+
+
+
+
+ + diff --git a/bootstrap/package.json b/bootstrap/package.json index 378006f..4dd70f1 100644 --- a/bootstrap/package.json +++ b/bootstrap/package.json @@ -5,9 +5,10 @@ "scripts": { "css-compile": "sass --load-path node_modules --style compressed --no-source-map -q scss/style.scss:build/style.css", "css-prefix": "postcss --replace build/style.css --use autoprefixer --no-map", - "css-purge": "purgecss --keyframes --css build/style.css --content ref/template.html ref/index.js --output css/", + "css-purge": "purgecss --keyframes --css build/style.css --content ref/template.html ref/index.js index.html --output css/", "css": "npm run css-compile && npm run css-prefix && npm run css-purge", - "css-server": "sass --load-path node_modules -q scss/style.scss:../server/static/style.css", + "css-dev": "sass --load-path node_modules -q scss/style.scss:build/style.css", + "css-server": "sass --load-path node_modules --no-source-map -q scss/style.scss:../server/static/style.css", "serve": "http-server ./" }, "keywords": [], diff --git a/config/config.go b/config/config.go index 04a3d90..ff549a0 100644 --- a/config/config.go +++ b/config/config.go @@ -17,7 +17,7 @@ type Config struct { func New() *Config { return &Config{ ServerAddr: getEnv("SERVER_ADDR", "localhost:8080"), - PostgresURL: getEnv("POSTGRES_URL", "postgres://postgres:demopsw@localhost:5432/microservices"), + PostgresURL: getEnv("POSTGRES_URL", "postgres://postgres:postgres@localhost:5432/microservices"), RabbitURL: getEnv("RABBIT_URL", "amqp://guest:guest@localhost:5672"), Exchange: getEnv("EXCHANGE", "main_exchange"), QueueBack: getEnv("QUEUE_BACK", "backend_queue"), diff --git a/react/package.json b/react/package.json index d1022d7..13e324d 100644 --- a/react/package.json +++ b/react/package.json @@ -4,7 +4,8 @@ "description": "", "scripts": { "build": "node esbuild.js", - "build-server": "esbuild src/index.jsx --bundle --sourcemap --outdir=../server/static" + "build-server": "esbuild src/index.jsx --bundle --outdir=../server/static", + "serve": "esbuild src/index.jsx --outfile=index.js --bundle --sourcemap --serve=8000" }, "keywords": [], "author": "", diff --git a/react/src/app.jsx b/react/src/app.jsx index f38ecaa..a5a00de 100644 --- a/react/src/app.jsx +++ b/react/src/app.jsx @@ -68,7 +68,7 @@ function App(){ React.useEffect(() => { clearTimeout(timeout.current); - timeout.current = setTimeout(() => {setAlerts([])}, 15000); + timeout.current = setTimeout(() => {setAlerts([])}, 20000); return () => { clearTimeout(timeout.current); diff --git a/react/src/index.jsx b/react/src/index.jsx index 1deae34..61eca0f 100644 --- a/react/src/index.jsx +++ b/react/src/index.jsx @@ -2,7 +2,7 @@ import * as React from 'react' import * as ReactDOM from 'react-dom' import App from './app'; -ReactDOM.hydrate( +ReactDOM.render( , document.getElementById('root') ); diff --git a/server/template.html b/server/template.html index 707ad3e..4300e45 100644 --- a/server/template.html +++ b/server/template.html @@ -23,19 +23,12 @@
-
- - - -
+
+