From 96c72aa6d865ad6561b1d7ff754fa892cb2752c1 Mon Sep 17 00:00:00 2001 From: MohammadReza Tayyebi Date: Thu, 5 Oct 2023 22:24:28 +0330 Subject: [PATCH] Added _run with docker_ method to the guide. --- examples/simpleMircoservice/README.md | 210 +++++++++++++------------- 1 file changed, 106 insertions(+), 104 deletions(-) diff --git a/examples/simpleMircoservice/README.md b/examples/simpleMircoservice/README.md index ffcdf69e..b0d7ace0 100644 --- a/examples/simpleMircoservice/README.md +++ b/examples/simpleMircoservice/README.md @@ -1,114 +1,116 @@ -### this is just very simple microserve example +# An example of implementing a micro-service architecture -in this example we have two microserve : +Current example demonstrates two micro-services known as `core` and `ecommerce` located in directories with same naming, with basic API functionality in between. -- one named `core` which includes `user` and `country` schema with just two action know as `addCountry` and `adduser`. - - you can run this server by runnig below line on `core/` folder: - ```bash - deno run -A mod.ts - ``` - this service respond to `HTTP POST` request to `http://localhost:8080/lesan` with this `JSON` on request body : - ```bash - { - "contents": "dynamic", - "wants": { - "model": "user", - "act": "addUser" - }, - "details": { - "set": { - "name": "Seyyedeh Sare Hosseini", - "address": "Iran, Hamedan", - "age": 5 - }, - "get": { - "age": 1, - "address": 1 - } - } +## Running this example +To run each example, navigate to corresponding directories (using `cd ecommerce` or `cd core` command) and choose one of the prefered methods below: +### Method 1: OS Shell +```bash +deno run -A mod.ts +``` +### Method 2: Docker container +```bash +docker run -it -v "${PWD}:/app" denoland/deno deno run --allow-all /app/mod.ts +``` + +The `core` microservice respond to `HTTP POST` request to `http://localhost:8080/lesan` with this `JSON` on request body mapped to its only actions defined (`addCountry` and `addUser`): +```bash +{ + "contents": "dynamic", + "wants": { + "model": "user", + "act": "addUser" + }, + "details": { + "set": { + "name": "Seyyedeh Sare Hosseini", + "address": "Iran, Hamedan", + "age": 5 + }, + "get": { + "age": 1, + "address": 1 } - ``` - and - ```bash - { - "contents": "dynamic", - "wants": { - "model": "country", - "act": "addCountry" - }, - "details": { - "set": { - "name": "iran", - "description": "Nice and great country" - }, - "get": { - "name": 1 - } - } + } +} +``` +and +```bash +{ + "contents": "dynamic", + "wants": { + "model": "country", + "act": "addCountry" + }, + "details": { + "set": { + "name": "iran", + "description": "Nice and great country" + }, + "get": { + "name": 1 } - ``` - it also can respond to `ecommerce` service request by adding `service` key to JSON body : - ```bash - { - "service": "ecommerce", - "contents": "dynamic", - "wants": { - "model": "wareType", - "act": "addWareType" + } +} +``` +it also can respond to `ecommerce` service request by adding `service` key to JSON body : +```bash +{ + "service": "ecommerce", + "contents": "dynamic", + "wants": { + "model": "wareType", + "act": "addWareType" + }, + "details": { + "set": { + "name": "digital", + "description": "digital stuff like phone and ..." }, - "details": { - "set": { - "name": "digital", - "description": "digital stuff like phone and ..." - }, - "get": { - "name": 1 - } + "get": { + "name": 1 } - } - ``` -- another named `ecommerce` which includes `ware` and `wareType` schema with two action `addWare` and `addWareType`. - - you can run this server by runnig below line on `ecommerce/` folder: - ```bash - deno run -A mod.ts - ``` - this service respond to `HTTP POST` request to `http://localhost:8585/lesan` with this `JSON` on request body : - ```bash - { - "contents": "dynamic", - "wants": { - "model": "wareType", - "act": "addWareType" + } +} +``` +In the other case `ecommerce` which includes `ware` and `wareType` schema with two action `addWare` and `addWareType`. +this service respond to `HTTP POST` request to `http://localhost:8585/lesan` with this `JSON` on request body : +```bash +{ + "contents": "dynamic", + "wants": { + "model": "wareType", + "act": "addWareType" + }, + "details": { + "set": { + "name": "digital", + "description": "digital stuff like phone and ..." }, - "details": { - "set": { - "name": "digital", - "description": "digital stuff like phone and ..." - }, - "get": { - "name": 1 - } + "get": { + "name": 1 } - } - ``` - and - ```bash - { - "contents": "dynamic", - "wants": { - "model": "ware", - "act": "addWare" + } +} +``` +and +```bash +{ + "contents": "dynamic", + "wants": { + "model": "ware", + "act": "addWare" + }, + "details": { + "set": { + "name": "GLX phone", + "brand": "GLX", + "price": 159 }, - "details": { - "set": { - "name": "GLX phone", - "brand": "GLX", - "price": 159 - }, - "get": { - "name": 1 - "price": 1 - } + "get": { + "name": 1 + "price": 1 } - } - ``` + } +} +```